I have created image view through code like this -

- (void)viewDidLoad
  [super viewDidLoad];
  // Do any additional setup after loading the view, typically from a nib

  UIImageView *dot =[[UIImageView alloc] initWithFrame:CGRectMake(50,50,20,20)];
  dot.image=[UIImage imageNamed:@"draw.png"];
  [self.view addSubview:dot];


I want to add User Interaction to this UIImageView and then create a selector or action for this UIImageView when tapped how is this done?

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

    // initialize cell

    if let pickerCell = cell as? SettingsPickerCell {

    return cell

The code above works, albeit is as ugly as hell. I have a scrollView buried deep in a view hierarchy, and I need a better way to disable the collection view scrolling when the picker is scrolling.

I tried using the exclusiveTouch property, didn't help. Is there a better way than this?

My paid app has been rejected by apple with reason:

If your app does not serve ads, please check your code - including any third-party libraries - to remove any instances of:

class: ASIdentifierManager
selector: advertisingIdentifier
framework: AdSupport.framework

If you are planning to incorporate ads in a future version, please remove the Advertising Identifier from your app until you have included ad functionality.

My app doesn't have any ad network sdk. Pls see following screenshot: enter image description here

I open the folder location of project in terminal and ran the command "grep -r advertisingIdentifier ." but nothing was returned

Any suggestion on how can I identify and get rid of this.

I have a function in ViewController that I would like to perform from a UIButton in ProfileViewController. How would I do this? Below is the code I have tried.

Code in ViewController

func hideProfileButton (sender:AnyObject) {
    self.profileButtonOutlet.hidden = true

Code in ProfileViewController


How would I set it if I have one main view controller and whenever I add another view controller to main.storyboard, it would have the exact same content and objects as the first one? Essentially, how would I be duplicating ViewControllers without having to build them again?

 labelTime.text = @"Hello";
 labelTime.text = @"Help Would be Appreciated";
 labelTime.text = @"Thaaanks ";

What would you think is the best strategy to load an optional UIViewController? Here is the current setup:

I'm using this library https://github.com/flubbermedia/FMRevealViewController which basically mimics the now very common setup with a mainViewController and a sideViewController which is "revealed" when a user swipes left or right (a la Facebook).

BTW... normally I would set up both the view controllers (main and side) in the AppDidFinishLaunching. However I have an app where the sideViewController takes a little to load (around 0.3s). For a number of reasons I can't get around it. At the same time it's essential that the app loads as fast as possible. Finally I can't load it when a user swipes... because it would result in a noticeable delay in the loading.

What I'd like to achieve then, is some sort of "deferred preloading".

I basically need to preload the sideViewController... but only after the mainViewController is fully loaded and visible on screen.

My first attempt was by using a dispatch_after in the appDidFinishLaunching to delay the loading of the sideViewController for two seconds... but it's not a very robust solution.

Now I'm thinking to move the loading of the sideViewController into the viewDidAppear method of mainViewController... but I'm not crazy about this solution either.

What would you do?

I've been learning HTML5/CSS3 for a month now, and I've built my first demo website. At first I was using a lot of the element selectors like: >, ,, + in combination with the type names for selecting nested tags.

Now I've moved more to the id and class selectors and use the >, ,, + less often for selecting nested tags.

Is using id and class selectors a better approach for selecting tags which are (deeply) nested? Are there any downsides to this approach? Or is it just a matter of style?

There's my problem...

I have the following variables:

$days_a = $array_total['days']; // This one display days 
$hours_a = $array_total['hours']; // This one display hours
$minutes_a = $array_total['minutes']; // This one display minutes
$seconds_a = $array_total['seconds']; // This one display seconds

These variables give me the current session time, here all works.

Now the problem...

I have then these variables:

$days_f = $fetch_s['days'];
$hours_f = $fetch_s['hours'];
$minutes_f = $fetch_s['minutes'];
$seconds_f = $fetch_s['seconds'];

These display the time that the user entered in the website previously, they took the values from the database... I did this for add the current session variable values to the values in the MySQL Db:

   $days_2 = $days_a + $days_f;
   $hours_2 = $hours_a + $hours_f;
   $minutes_2 = $minutes_a + $minutes_f;
   $seconds_2 = $seconds_a + $seconds_f;

But I need that each 60 seconds it add 1 to $minutes_2 , each 60 minutes it add 1 to $hours_2 and each 24 hours it add 1 to $days_2

For example if I have 118 seconds I need that it adds 1 to $minutes_2 and set the variable $seconds_2 to 58 etc...

How can this be done?

I tried something like that:

   $seconds = $seconds_2 % 60;
    $minutes_3  = $seconds_2 / 60;
     $minutes  = $minutes_3  % 60;
      $hours_3   = $minutes  / 60;
       $hours    = $hours_3  % 24;
        $days   = $hours  / 24;

          $days = (int)$days_int;

But this won't work... Someone know how do that in a similar or different way?

Thanks :)

You are given an array of a given length.

Now we have to determine whether we can Divide the array into n sub-array such that all of them have equal sum . Note: Each sub-array may or may not have equal length

As an Example to this is

Array is

1 2 3 4 5

and given number is n=3 then you have to find whether u can create 3 sub-arrays such that all of them have equal sum.

In the above case it is possible as




are the 3 sub-arrays.

Another Example is

Let the array be a[]={1,2,4,5,6} and value of n=3

Then u have to determine whether 3 sub-arrays(whose length may not be same) exist such that there elements sum are equal.

In the above case the 3 sub-arrays are

{1,5} {6} {2,4}

Each are of equal or same sum i.e. 6.

My Question is that can anybody provide me any algorithm that is correct enough for this.

My Approach:

Take the sum of the array elements

Divide it by n.

let k=sum/n;

then check whether there exist 3 subset or sub-array whose sum is equal to k.

keep getting these messages

[2014-12-12 20:04:40 - ddms] Can't bind to local 8610 for debugger
[2014-12-12 20:04:40 - ddms] Can't bind to local 8626 for debugger
[2014-12-12 20:04:41 - ddms] Can't bind to local 8607 for debugger
[2014-12-12 20:04:42 - ddms] Can't bind to local 8636 for debugger
[2014-12-12 20:04:44 - ddms] Can't bind to local 8614 for debugger
[2014-12-12 20:04:44 - ddms] Can't bind to local 8639 for debugger
[2014-12-12 20:04:46 - ddms] Can't bind to local 8607 for debugger
[2014-12-12 20:04:47 - ddms] Can't bind to local 8610 for debugger
[2014-12-12 20:04:48 - ddms] Can't bind to local 8624 for debugger
[2014-12-12 20:04:48 - ddms] Can't bind to local 8626 for debugger
[2014-12-12 20:04:51 - ddms] Can't bind to local 8635 for debugger
[2014-12-12 20:04:56 - ddms] Can't bind to local 8614 for debugger
[2014-12-12 20:05:11 - ddms] Can't bind to local 8607 for debugger
[2014-12-12 20:05:11 - ddms] Can't bind to local 8610 for debugger
[2014-12-12 20:05:12 - ddms] Can't bind to local 8624 for debugger
[2014-12-12 20:05:15 - ddms] Can't bind to local 8626 for debugger

I have windows 8 and the latest jre 8

I tried:

  1. restarting adb

2.disabling avg

  1. adding to localhost

  2. window-preferences-android-ddms - all that stuff

what else?

im going crazy here

I'm trying to send a request using Volley but I can't figure how to make it work.

I need to send a POST request with JSON encoded data as the body, but after hours of trying different things I still can't make it work.

This is my current code for the request:

    User user = User.getUser(context);
    String account = user.getUserAccount();
    String degreeCode = user.getDegreeCode();

    final JSONObject body = new JSONObject();
    try {
        body.put(NEWS_KEY, 0);
        body.put(NEWS_DEGREE, degreeCode);
        body.put(NEWS_COORDINATION, 0);
        body.put(NEWS_DIVISION, 0);
        body.put(NEWS_ACCOUNT, account);

    } catch (JSONException e) {

    StringRequest request = new StringRequest(Request.Method.POST, GET_NEWS, new Response.Listener<JSONObject>() {
        public void onResponse(String response) {
            Log.i(TAG, response);
    }, new Response.ErrorListener() {
        public void onErrorResponse(VolleyError error) {
            Log.e(TAG, "Error: " + getMessage(error, context));
            Toast.makeText(context, getMessage(error, context), Toast.LENGTH_SHORT).show();
        public byte[] getBody() throws AuthFailureError {
            return body.toString().getBytes();

        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> headers = new HashMap<>();
            return headers;

But this code always returns "Bad request error"

Some things I've tried:

  • Override getParams() method instead of getBody(). (Didn't work)
  • Send a JSONObjectRequest with the body on the constructor. This one worked, but because my web service returns a String value I always get a ParseError. That's why I'm using StringRequest

Any help is very much appreciated

Any idea how to draw circle with blur effect when the acceleration is turned on inside the manifest file ?

I'm trying to rewrite this code in qml using c++.

import QtQuick 2.0
import QtMultimedia 5.4

Rectangle {
    id : cameraUI

    color: "black"

    Camera {
        id: camera
        captureMode: Camera.CaptureStillImage

        videoRecorder {
             resolution: "640x480"
             frameRate: 30

    VideoOutput {
        id: viewfinder
        visible: true
        width: parent.width
        height: parent.height

        source: camera
        autoOrientation: true

The main idea is simple - display camera stream.

I tried to do it this way:

#include <QApplication>
#include <QCamera>
#include <QCameraViewfinder>

int main(int argc, char *argv[])
    QApplication app(argc, argv);

    QCameraViewfinder* viewfinder = new QCameraViewfinder;

    QCamera* camera = new QCamera;


    camera->start(); // to start the viewfinder

    return app.exec();

This code perfectly works on desktop, but shows nothing on android device. Where am I mistaken?

I'm removing a child from a parent with animateLayoutChanges on. I want to know when the animation is complete, but can't get the listener to fire:


    <TextView android:id="@+id/child" />


void testRemove() {
    ViewGroup parent = (ViewGroup)findViewById(R.id.parent);

    TextView child = findViewById(R.id.child);
    child.setVisibility(View.GONE); // this triggers the animation.

Animation.AnimationListener listener = new Animation.AnimationListener() {
    public void onAnimationStart(Animation animation) {
        // None of these callback methods fire.

Any ideas why the listener wouldn't fire?



The Wifi login with Android 5 has changed fundamentally. The redirect (e.g. with a DD-WRT NoCatSplah landing page) is not directly ignored, but it closes after the user clicks on accept-button (now displayed in a new modal view not any more in android for chrome browser).

I think there are a lot of companies affected because they show on redirect (home) page local information, time remaining without paying in Wifi network or ads. E.g.: big Wifi providers or hotels....

Does anyone know a specification-link for this new Android 5 behavior? Or how to handle it to open e.g. a chrome tab for redirection after clicking on accept-button to enter the Wifi network (old behavior - workaround)?! E.g. Window.open does not work in this new "modal view".

On my DD-WRT router I use NoCatSplash with the following splash.html:

<p><b><font size="10">Welcome to my WiFi</font></b></p>

<form name="login" method="post" action="">
<input type="hidden" name="accept_terms" value="yes" />      
<input type="hidden" name="redirect" value="http://my-homepage.html">
<input type="hidden" name="mode_login">
<input type="submit" value="I agree, connect me to WLAN!">

I also tried to allow the IP addresses on router (wallet garden) which try to connect to internet when modal view appears (I think they check if the splash.html should be shown in modal view or not). But no luck.

It would be optimal to make the old behavior happen on Android 5. The splash.html should be shown only if a user opens the mobile web browser and tries to open a website the first time. (no notification on Android and modal view).

For further information about this see also: http://community.spiceworks.com/topic/638688-splash-pages-redirect-on-android-lollipop-5

I've just started with Android Studio and I'm finding it hard to see the name of the apk file I want to put in the Google Play so that lots of people can buy it.

Ler's say I want the name of the app to be "Happy Days" where in the many parts of Android Studio should I put this phrase? I would like the apk to be HappyDays.apk. The package is com.companyname.happydays

I've been trying to create a wifi connection to proxy custom port, I tested with the class that is available at: https://gist.github.com/madeye/2297083

But I have a problem when invoking the method setproxy (), which in turn calls a setICSProxy () and error that throws me is:

12-12 16: 52: 13.711: E / TestConnection (19130): java.lang.ClassNotFoundException: android.webkit.WebViewCore

in the line:

 Class webViewCoreClass = Class.forName ("android.webkit.WebViewCore");

Also try this:

System.setProperty ("http.proxyHost" <your proxy host name>);
System.setProperty ("http.proxyPort" <your proxy port>);

But either way test, the connection is successfully created but without proxy and port.

What I recommend doing or that way I can solve this problem?

Thank you!

How is color addition done in android? For my pathtracer i am storing a Color but i didn't find a way to get the r,g,b values back.

I think if i want to get red i do this:


but it doesn't work.

Since i work more with android in the last week i do more and more think why stuff is made so complicated in android? In C# you just add the r,g,b values and you don't get an integer back if you type


My team is in the planning stages for an app that will span multiple platforms, and I am trying to figure out how to handle its version control. There will be:

  • an iOS app (has its own Git repo, on GitHub)
  • an Android app (has its own Git repo, on GitHub)
  • a Google App Engine backend for the iOS and Android app

How can I Git, or some other tool like Repo, so both iOS and Android can easily share the same App Engine code?

Note: I want to take advantage of the Android Studio built-in App Engine functionality.

I'm trying to solve a problem, how to store Public Transport data efficiently for obtaining and representing it in Android. The simplified use of my class is this: user select the bus number using spinner, then he selects the stop at specified street (also using spinner). And after that he clicks the submit button and the timetable of the bus at specified street shows up in the fragment below the submit button. The main question is: what's the best structure to store Public Transport data? Three dimensional array, HashMap, Map or something else? You can find a live example here: http://marijampolietis.balsas.lt/miesto-autobusu-tvarkarastis/ P.S. Right now, I'm storing both spinners data in strings.xml array

Quick question:

I know a small amount of Java, and I'm working on my first very basic Android application.

I just want it to say "Your device is: Build.MODEL" but I can't figure out how to get that string to display in the XML TextView.