Showing and refreshing advertisement - iphone

I want to show an advertisement in my application, and after some time I want to refresh it and show another advertisement. How can I do this? Please help me give some sample code.
I am new to iPhone programming. Thanks in advance.

Use NSTimer. In the Firemethod you can change UIImageview's image.you can maintain flag variable in that method.suppose the firemethod is called every one second, the flag variable will be incremented, it it equals to 5, show one image, if it equals to 10, you can show another image.reset flag variable in after showing last image..

Related

Mupdf: how to reset the resolution of pdf view page PROPERLY when the CDialogEx(MFC) OnSize?

my pdf file is rendering in a CDialogEx(it's MFC Class),and what i want is to reset the resolution when the Dialog resized.....
I find a solution via the mupdf offical downloads site:first set the desired resolution with pdfapp_setresolution(...), then call pdfapp_reloadpage(...). This reaches my goal but not perfect, with this method the displaying dialog gets a conspicuous redrawing (first the background color, then recovered back normal)...
anybody have a better optimization? thanks
1st. resize the pdfapp_t object according to the view_window size via API pdfapp_onresize()
2nd. adjust the resolution of pdfapp_t object//#attentison# here the resolution needs some transformation on the basis of yr actual requirement, referencing the API pdfapp_autozoom() in pdfapp.c source file.
3rd. show page via pdfapp_showpage()
thats all :) maybe helpful to sb.
PS:lesson is that referencing the official document or example in details first :)

Property additionalActions of NSUserNotification seems not working?

To understand NSUserNotification better, I wrote a little test app playing with this class.
So far so good, except that no matter how hard I tried to feed the additionalActions property with array of NSUserNotificationAction objects, it never showed any difference but only one action button and a close one.
My expectation for this property is that the notification would show a pull-down menu containing the additional buttons I offer as it does in the Mac App Store update notifications.
Am I missing something? Or are you having the same problem, since it is a bug awaiting Apple to tackle?
Can you please try to click and hold down the action button in your notification? Does it show a drop-down menu of additionalActions?
Update
As it turns out, you can show the little chevron next to the action button by setting a true value for the private _alwaysShowAlternateActionMenu key on the notification. In Swift 3, it would look like this:
notification.setValue(true, forKey: "_alwaysShowAlternateActionMenu")
However, as I mentioned this is a private API and I strongly advise against using it if you want to distribute your App through the Mac App Store.
It is probably a bug. Setting up additionalActions will create the list, but not the little arrow icon. Holding down on actionButton will show the menu with the number of actions you set.
Besides setting additionalActions will cause several other problems. I will save this for another question.
Refer to another question.
show NSUserNotification additionalActions on click
P.S. I am using El Capitan APIs

Robotium : Is there a way to check for an activity to NOT exist?

I'm automating an app that shows some overlay messages anywhere on the app for several scenarios, such as app installed for the first time etc. (I'm fairly new to Robotium too.)
The overlay displays a text that goes away by swiping or clicking on it. Also, there are different types of these overlays with different unique text on it. (let's call it Activity A)
I wanted to create a robust test case that handles this case gracefully. From the test's perspective we won't know that the activity A will be present all the time. But I want to recover from the scenario if it does, by writing a method that I can call any time. Currently, the tearDown method gets called since my expected activity name doesn't match.
Also, even if the activity A exists, there are other predefined overlay texts too. So, if I use solo.waitForText("abc") to check for text "abc", I may see the overlay 2 with the text "pqr" instead.
So I was looking for a way to automate this, and I can't use solo.assertCurrentActivity() or solo.waitForActivity methods as they just stop the execution after the first failure.
So any guidance is appreciated!
All the waitFor methods return a boolean. So you can use waitForActivity() exactly as you want to. If the Activity doesn't exist it will return false.
You can check which Activity is current:
Activity current = solo.getCurrentActivity();

iOS: selecting option returns null first time, not second time

I have an iOS application where you select an option before you log in. The way it works is that you click on the button that says "Select", then it takes you to a UITableViewController which shows you the options, you select the option, and it takes you back to the previous menu with the text replaced with your selection (and a hidden ID saved, too).
During the update of the information (which takes place in tableView:didSelectRowAtIndexPath:) I call NSLog on the object. The first time I call it, it returns null (BUT for some reason the text still changes!) and the second time I call it, it works! Why doesn't it work the first time????
Thanks
Do you put the NSLog line before the previous view push back code ?
The variable was named incorrectly. I don't know why XCode didn't just tell me this instead of giving me an EXC_BAD_ACCESS, but that's what happened.

SegmentControll problem in iphone

A new bie here...
I am using a segmentController..in that there are three segments...Say segment A,B,C
Now I want this functionality...
when I press Segment A..Table A comes up..
when I press Segment B..Table B comes up..and
when I press Segment c..Table C comes up
well I know all the label change and that stuff...but what about the tables?? and again when I press the row elements they navigates me to another views and I want segment control to be displayed in navigated view also..
well ... can anyone please tell me how to do this??
any suggestion..any tutorial..any example code...any logic...anything....:)
Here is the link shows the simple Segment control. And when you want to add a Table , it is having the sample process , connect the delegates and data source. HERE is the descussion on the kind of similar question as your one.
This is the Class Reference of Segment control, which provides you a lot many examples this shall help you.
Hope this will help you.