Trying to access UINavigationController from within AppDelegate - ios

Ok, I'm still pretty new to iOS development, so I apologize if this is a silly question.
But, I have an AlertView that I call from the AppDelegate then respond when clicking a button in the alert. I can do a NSLog and see that the methods are getting called. But, it's not pushing the view into the stack. Here's a sample of what I have (I'm sure it's wrong):
This is in the AppDelegate.m:
#import "AppDelegate.h"
#import "ProfileConnection.h"
#implementation AppDelegate
#synthesize window = _window;
#synthesize navController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}
-(void)switchToController:(NSString *)controller animated:(BOOL)animated{
NSLog(#"switching to controller %#", controller);
// maybe we can do a check to see if a subview exists...and then push or pop accordingly.
// switch to the "TableView" view
if( [controller isEqualToString:#"ProfileConnection"]){
NSLog(#"switching to the ProfileConnection view");
ProfileConnection *profile = [[ProfileConnection alloc] initWithNibName:#"ProfileConnection" bundle:nil];
[self.navController pushViewController:profile animated:YES];
}
}
-(void)showConnectionFoundAlert
{
NSString *connectFoundMsg = [[NSString alloc] initWithFormat:#"We found someone we'd think you would like to meet: Tony Davis"];
UIAlertView *connectionFoundAlert = [[UIAlertView alloc] initWithTitle:#"Connection Found" message:connectFoundMsg delegate:self cancelButtonTitle:#"Decline" otherButtonTitles:#"Connect", #"View Profile", #"Save For Later", nil];
[connectionFoundAlert show];
//[connectionFoundAlert release];
}
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
NSString *alertString = [[NSString alloc] initWithFormat:#""];
if([title isEqualToString:#"Decline"])
{
alertString = #"Declied";
}
else if([title isEqualToString:#"Connect"])
{
alertString = #"Connected";
}
else if([title isEqualToString:#"View Profile"])
{
//alertString = #"Profile Viewed";
//NSLog(#"View Profile is being called");
[self switchToController:#"ProfileConnection" animated:YES];
//UIViewController *profile = [[UIViewController alloc] initWithNibName:#"ProfileConnection" bundle:nil];
//ProfileConnection *profile = [[ProfileConnection alloc] initWithNibName:#"ProfileConnection" bundle:[NSBundle mainBundle]];
//UINavigationController *nav = [[UINavigationController alloc] init];
//[nav pushViewController:profile animated:NO];
/*UIViewController *profile = [[UIViewController alloc] initWithNibName:#"ProfileConnection" bundle:nil];
UINavigationController *navigation = [[UINavigationController alloc] init];
[navigation pushViewController:profile animated:YES];*/
/*
ProfileConnection *profile = [ProfileConnection alloc];
//UIView *current = self.window;
[self.window addSubview:profile.view];
*/
/*
[window addSubview:view1.view];
[window makeKeyAndVisible];
- (void)goToNextPage {
view2 = [ViewController2 alloc];
UIView *current = self.window;
[self.window addSubview:view2.view];
*/
}
else if ([title isEqualToString:#"Save For Later"])
{
alertString = #"Saved It";
}
UIAlertView *alertStr = [[UIAlertView alloc] initWithTitle:#"" message:alertString delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
if ([alertString isEqualToString:#""]) {
} else {
[alertStr show];
}
}
#end
This is the AppDelegate.h:
#import <UIKit/UIKit.h>
#import "ProfileConnection.h"
#interface AppDelegate : UIResponder <UIAlertViewDelegate, UIApplicationDelegate, UINavigationControllerDelegate> {
UINavigationController *navController;
}
#property (strong, nonatomic) UIWindow *window;
#property (nonatomic, retain) UINavigationController *navController;
-(void)showConnectionFoundAlert;
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;
-(void)switchToController:(NSString *)controller animated:(BOOL)animated;
#end
I am able to add the view with this, but I lose my navigation controller:
ProfileConnection *profile = [ProfileConnection alloc];
[self.window addSubview:profile.view];
You can see I have tried a few approaches, but I'm confusing myself trying to use the storyboard approach.
Also, the ProfileConnection view is blank with a single label at the moment, if that helps.

You code looks ok [self.navController pushViewController:profile animated:YES]; is how you should do it.
You should make sure that you have added the navigation controller to the window. Perhaps this should already be done by the storyboard, but if not user the rootviewcontroller property of the window (its better than addSubview).
self.window.rootViewContorller = self.navController;
Now do a sanity check to make sure nothing is nil (profile or the navController).
NSLog(#"%# %#",self.navController, profile);
Does any of that help?

Related

Can not change text from a label in objective c

I am working on a app in objective c. Now i want a label to change text with the username's name after login. For some reason this don't work
Here is my code
#import "ViewController.h"
#interface ViewController ()
#property (strong, nonatomic) IBOutlet UITextField *userNameTextField;
#property (strong, nonatomic) IBOutlet UITextField *passwordTextField;
#property (strong, nonatomic) IBOutlet UILabel *labelWelkom;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)Login:(id)sender {
if ([_userNameTextField.text isEqualToString:#""] || [_passwordTextField.text isEqualToString:#""]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"alert" message:#"Please Fill all the field" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
return;
}
NSString *strURL = [NSString stringWithFormat:#"http://localhost:8888/swift/login.php?userName=%#&password=%#",_userNameTextField.text, _passwordTextField.text];
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
if ([strResult isEqualToString:#"1"])
{
NSString *username = _userNameTextField.text;
_labelWelkom.text = [NSString stringWithFormat:#"Hello %#", username];
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:#"logedIn"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];
}
else if ([strResult isEqualToString:#"0"])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"alert" message:#"Wrong username / password" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
return;
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"alert" message:#"Server Error" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
return;
}
}
#end
Here is a image of my storyboard
In the left bottom you see my first page after login it loads the second page (upper right corner) in this page is the label that needs to change.
I think you set text of label before creating an instance. Try to assign after creating
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:#"logedIn"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];
_labelWelkom.text = [NSString stringWithFormat:#"Hello %#", username];
I got some remarks :
.Your _labelWelkom is referring to your Login view controller. Where is the declaration of the loggedIn view label ?
.You defined an IBAction through Interface Builder. So why don't you use
(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
to present your 'loggedIn view' instead of instantiating and presenting this view programmatically here ?
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:#"logedIn"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];
If we preserve the present IB, let us remind that there is, as far as I know, two main ways to access your label in the second view :
Using IB :
Create another ViewController,i.e .h and .m files.
Link it to your 'Logged in' view controller in IB (through the Identity Inspector)
Link your label as an IBOutlet to your new view controller
In this first case, you should have a class in charge of getting your username after a successful login action. Using NSUserDefault is a way, among others to do this (check Stackoverflow Q&A to get more information).
Programmatically with keeping your IB as it is
Put a tag on your label in IB. Ex : 100.
In this second case, you can put text value to your UILabel within the first view controller implementation.
You can access it after your loggedIn view instantiation through :
UILabel* yourlabel =(UILabel*) [yourView viewWithTag: 100];
Look at this Q&A page :
How can I programmatically access UI elements in a NIB without 'wiring' them?
In this second case, you can put text value to your UILabel within the first view controller implementation.
I hope this will help you.

UIDatePicker memory leak in IOS 8.3

I am seeing memory leaks in UIDatePicker when used in a popover on an iPad running IOS 8.3. I'm getting approx 5K in multiple memory leaks every time the date picker is popped up and then dismissed. The leaked object is NSDateComponents, and the responsible frame is [_UIDatePickerMode _yearlessYearForMonth:].
I have written a simple test app to demonstrate the problem (https://github.com/david-ape/datepickertest/). I've included both a UIPopoverController option and a UIPopoverPresentationController option, but it doesn't seem to matter which is used.
Am I doing something wrong, or is there a workaround, or do I need to wait for a fix from Apple? If the latter, then can anyone suggest a third party control that I could use in place of UIDatePicker?
Below is the code I'm using to pop up the date pickers.
Header file
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController <UIPopoverControllerDelegate,
UIPopoverPresentationControllerDelegate>
#end
Implementation file
#import "ViewController.h"
#interface ViewController ()
#property (nonatomic, strong) UIPopoverController *ios7Popover;
- (IBAction)datePickerPopupIOS7:(UIButton *)sender;
- (IBAction)datePickerPopupIOS8:(UIButton *)sender;
#end
#implementation ViewController
// helper - returns a view controller containing a date picker for use in a
// popup
+ (UIViewController *)buildDatePickerViewController
{
CGRect frame = CGRectMake(0, 0, 350, 216);
UIViewController *viewController = [[UIViewController alloc]init];
viewController.preferredContentSize = frame.size;
UIDatePicker *datepicker = [[UIDatePicker alloc]initWithFrame:frame];
datepicker.datePickerMode = UIDatePickerModeDate;
datepicker.hidden = NO;
datepicker.date = [NSDate date];
[viewController.view addSubview:datepicker];
return viewController;
}
// popup date picker using UIPopoverController (IOS7 compatible)
- (IBAction)datePickerPopupIOS7:(UIButton *)sender
{
UIViewController *viewController = [ViewController buildDatePickerViewController];
self.ios7Popover = [[UIPopoverController alloc]initWithContentViewController:viewController];
self.ios7Popover.delegate = self;
[self.ios7Popover presentPopoverFromRect:sender.frame
inView:self.view
permittedArrowDirections:(UIPopoverArrowDirectionUp|UIPopoverArrowDirectionDown| UIPopoverArrowDirectionLeft|UIPopoverArrowDirectionRight)
animated:YES];
}
// popup date picker using UIPopoverPresentationController (IOS8 or later required)
// Thanks to http://stackoverflow.com/a/26944036/1764243 for how to do this
- (IBAction)datePickerPopupIOS8:(UIButton *)sender
{
if ([UIPopoverPresentationController class])
{
UIViewController *viewController = [ViewController buildDatePickerViewController];
UINavigationController *destNav = [[UINavigationController alloc] initWithRootViewController:viewController];
destNav.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popover = destNav.popoverPresentationController;
popover.delegate = self;
popover.sourceView = self.view;
popover.sourceRect = [sender frame];
destNav.navigationBarHidden = YES;
[self presentViewController:destNav animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Not supported"
message:#"UIPopoverPresentationController not supported in this version of IOS"
delegate:nil
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
}
}
#pragma mark - UIPopoverControllerDelegate methods
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
self.ios7Popover = nil;
}
#end

Passing data between tabbarcontroller which have content view and view controllers

I am using xib instead of storyboard.
AppDelegate.m
ViewController1 *ViewController1 = [[ViewController1 alloc] init];
ViewController1.title = NSLocalizedString(#"1", #"1");
ViewController2 *ViewController2 = [[ViewController2 alloc] init];
ViewController2.title = NSLocalizedString(#"2", #"2");
BannerViewController *_bannerViewController1;
_bannerViewController1 = [[BannerViewController alloc] initWithContentViewController:ViewController1];
BannerViewController *_bannerViewController2;
_bannerViewController2 = [[BannerViewController alloc] initWithContentViewController:ViewController2];
_tabBarController = [[UITabBarController alloc] init];
_tabBarController.viewControllers = #[_bannerViewController1,_bannerViewController2];
self.window.rootViewController = _tabBarController;
[self.window makeKeyAndVisible];
ViewController1.m
#import "ViewController1.h"
#import "ViewController2.h"
ViewController2 *cvc = [[ViewController2 alloc] initWithNibName:nil bundle:nil];
cvc.strReceiveValue= "Testing";
ViewController2.h
#property (strong, retain) NSString *strReceiveValue;
ViewController2.m
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(#"strMortgageAmount: %#", strMortgageAmount);
Any idea why I failed to get the value? I was thinking this could be related to initWithContentViewController.
**
See update below
**
If I understand the question correctly, you are creating a tab bar controller (in AppDelegate?) and wish to pass information to the view controllers associated with the tab bar controller?
If so, take a look at this:
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
[tabBarController setDelegate:self];
UINavigationController *dashTVCnav = [[tabBarController viewControllers] objectAtIndex:0];
Then:
DashTVC *dashTVC = [[dashTVCnav viewControllers] objectAtIndex:0];
dashTVC.managedObjectContext = self.managedObjectContext;
dashTVC.uuid=uuid;
Then in DashTVC.h:
#property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
#property (strong, nonatomic) NSString *uuid;
With this, you pass the managedObjectContect and the uuid to the dashTVC controller.
I hope I understood what you are asking...
+++++++++++++++ UPDATE +++++++++++++++++++++
The original poster was kind enough to give me his sample code. I will post parts of it here with my fix for those who find this through searches in the future
There were several problems, but in short, nothing was being passed to vc2:
1st, nothing was being passed from the appDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
CGRect bounds = [[UIScreen mainScreen] bounds];
self.window = [[UIWindow alloc] initWithFrame:bounds];
self.window.backgroundColor = [UIColor whiteColor];
ViewController1 *vc1 = [[ViewController1 alloc] init];
vc1.title = NSLocalizedString(#"VC1", #"VC1");
ViewController2 *vc2 = [[ViewController2 alloc] init];
vc2.title = NSLocalizedString(#"VC2", #"VC2");
//--- I added this as a test
vc2.strReceiveValue=#"foo";
// and now foo shows up in the debug console when vc2 is fixed
_tabBarController = [[UITabBarController alloc] init];
_tabBarController.viewControllers = #[
[[BannerViewController alloc] initWithContentViewController:vc1],
[[BannerViewController alloc] initWithContentViewController:vc2],
];
self.window.rootViewController = _tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
Next, it was necessary to modify viewWillAppear in viewController2.m
- (void)viewWillAppear:(BOOL)animated {
// line below missing
[super viewWillAppear:animated];
NSLog(#"output: %#", strReceiveValue);
}
Hope this helps, and enjoy developing for IOS!

iPad Landscape Mode - How To Add Two Splash Screen

I have successfully finished my app after months of coding. Now I'm trying to add the initial Splash Screen images to my app. How do i proceed? I have two images: one is the company logo and the other is the app logo (these splash screens are to hide the loading time). I have looked every where for an possible answer, but ended up with no solution. When i name a single pic Default-Landscape.png and run the Ipad App - The image is showing until the main view controller loads up, but I want the first image to be displayed for 1 second and fade out to the second image which will also be displayed for 1 second after which the main view controller appears(the original application page).
I have checked various answers, but none seems to work - Xcode 4 and iPad2 splash screen issue
Setting splash images for portrait and landscape mode - IPad
etc..
Here is my code for the same - AppDelegate.h
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSArray *docDir=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docPath=[docDir objectAtIndex:0];
databasePath=[docPath stringByAppendingPathComponent:#"something.sqlite"];
//databasePath1=[docPath stringByAppendingPathComponent:#"something.sqlite"];
NSString *bundlePath=[[NSBundle mainBundle]pathForResource:#"something" ofType:#"sqlite"];
NSFileManager *mngr=[NSFileManager defaultManager];
if ([mngr fileExistsAtPath:databasePath]) {
NSLog(#"File Exists");
}
else
{
[mngr copyItemAtPath:bundlePath toPath:databasePath error:NULL];
NSLog(#"File Created");
}
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
How should I proceed now? Should I create a new class like (splashScreen 1 and splashScreen 2) with uiImageView and change the didFinishLaunchingWithOptions method? Any help would be greatly appreciated.
Updated: 30 May 2013
Appdelegate.h
#import <UIKit/UIKit.h>
#import "sqlite3.h"
#import "FBInteract.h"
#import "splashScreen1.h"
sqlite3 *dbHandler;
NSString *databasePath;
#class ViewController;
#interface AppDelegate : UIResponder <UIApplicationDelegate> {
UIWindow *window;
UINavigationController *naviObj;
}
#property (strong, nonatomic) UIWindow *window;
#property (strong, nonatomic) ViewController *viewController;
#property (strong, nonatomic) UINavigationController *naviObj;
#end
Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
splashScreen1 *splashScreen1PageObj=[[splashScreen1 alloc]init];
self.naviObj = [[UINavigationController alloc]initWithRootViewController:splashScreen1PageObj];
self.window.rootViewController = self.naviObj;
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
[self.window makeKeyAndVisible];
return YES;
}
splashScreen1.h and splashScreen2.h
#import <UIKit/UIKit.h>
#import "splashScreen2.h"
#interface splashScreen1 : UIViewController
{
IBOutlet UIImageView *imgObjSplashImage; // IBOutlet UIImageView *objSplashImage; - in splashScreen2.h
}
-(void)hideSplash;
-(void)navigationToMain;
-(void)showSplash;
#end
splashScreen1.m and splashScreen2.m
- (void)viewDidLoad
{
// Do any additional setup after loading the view from its nib.
[NSTimer scheduledTimerWithTimeInterval:1.2 target:self selector:#selector(showSplash) userInfo:nil repeats:NO];
self.navigationController.navigationBarHidden=YES;
[imgObjSplashImage setAlpha:0]; //objSplashImage instead of imgObjSplashImage in splashScreen2
[super viewDidLoad];
}
-(void)showSplash{
[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:1.2];
[imgObjSplashImage setAlpha:1]; //objSplashImage instead of imgObjSplashImage in splashScreen2
[UIImageView commitAnimations];
[NSTimer scheduledTimerWithTimeInterval:2.4 target:self selector:#selector(hideSplash) userInfo:nil repeats:NO];
}
-(void)hideSplash{
[UIImageView beginAnimations:nil context:NULL];
[UIImageView setAnimationDuration:1.4];
[imgObjSplashImage setAlpha:0]; //objSplashImage instead of imgObjSplashImage in splashScreen2
[UIImageView commitAnimations];
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:#selector(navigationToMain) userInfo:nil repeats:NO];
}
#pragma mark
#pragma mark - Navigation Coding
-(void)navigationToMain {
//[self dismissModalViewControllerAnimated:YES];
[self dismissViewControllerAnimated:NO completion:Nil];
ViewController *ViewControllerPageObj=[[ViewController alloc]init];
[self.navigationController pushViewController:ViewControllerPageObj animated:NO];
[ViewControllerPageObj release];
//[self presentViewController:ViewControllerPageObj animated:NO completion:Nil];
}
-(void)viewWillAppear:(BOOL)animated {
self.navigationController.navigationBarHidden=YES;
}
The problem is ViewController(main ViewController) is not loading...I'm getting error saying "message sent to deallocated instance" in viewDidLoad part of ViewController.m
RootViewController -> splashScreen1 -> splashScreen2 is working fine(with all the animation fading in and out) but the final ViewController is not loading..
For this you definitely want another VC, lets call it StartViewController. Add there an imageView, block rotation and setTimer:
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:#selector(moveOnAndChangeVC:) userInfo:nil repeats:NO];
and if you develop NavigationControl app you should also change rootVC for example:
+(void)replaceRootVCWithVC:(id)vc {
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:[[sharedAppDelegate navigationController] viewControllers]];
if(![viewControllers isEmpty])
[viewControllers replaceObjectAtIndex:0 withObject:vc];
else
[viewControllers addObject:vc];
[[sharedAppDelegate navigationController] setViewControllers:viewControllers];
}
EDIT:
You should change in your appDelegate line with initializer:
self.viewController = [[[StartViewController alloc] initWithNibName:#"StartViewController" bundle:nil] autorelease];
This should call your VC as a rootVC.
Then in StartViewController.m you should recognize device (this is a iPad only app, right? not universal) and orientation:
+(NSString*)recognizeDeviceAndOrientation {
NSMutableString * returnString;
if([StartViewController deviceInterfaceOrientation] == UIInterfaceOrientationLandscapeLeft || [StartViewController deviceInterfaceOrientation] == UIInterfaceOrientationLandscapeRight) {
returnString = #"Default-Landscape";
} else {
returnString = #"Default-Portrait";
}
if([UIScreen mainScreen].scale == 2.0)
return [NSString stringWithFormat:#"%#%#",returnString,#"#2x"];;
else
return returnString;
}
+(UIInterfaceOrientation)deviceInterfaceOrientation {
return [[UIApplication sharedApplication] statusBarOrientation];
}
This will return you a string with DefaultScreen name with proper orientation. If you handling only one orientation forget about it.
Then in viewDidLoad you add imageView:
- (void)viewDidLoad {
[super viewDidLoad];
UIImageView *imageView = [[[UIImageView alloc] initWithImage:[StartViewController recognizeDeviceAndOrientation]] autorelease];
[imageView setFrame:self.frame];
[imageView setContentMode:UIViewContentModeScaleToFill];
[self.view addSubview:imageView];
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:#selector(moveOnAndChangeVC:) userInfo:nil repeats:NO];
}
This will call a timer and set imageView.
-(IBACtion)moveOnAndChangeVC:(id)sender {
//if you using navigation app
ViewController *vc = [[[ViewController alloc] initWithNibName:#"ViewController" bundle:nil] autorelease];
[self.navigationController pushViewController:vc animated:NO];
}
This will work. And then if you want to get rid of "back button" just change a rootView Controller like i said in the beginning. Do it in your ViewController class.

Get data to other ViewController with custom UIActivity

I try to add custom icon to UIActivity, and i did it, but i can't set UIACtivity. I want hat when i click the icon open other ViewController and take text and image from UIActivity.
I have this code
- (UIViewController *)activityViewController
{
ViewController *viewController = [[[ViewController alloc] init] autorelease];
viewController.activity = self;
viewController.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
return viewController;
}
but this don't work
- (void)performActivity
{
ViewController *viewController = [[[ViewController alloc] init] autorelease];
[viewController.textField1 setText:self.message];
[viewController.imageView setImage:self.image];
[self activityDidFinish:YES];
}

Resources