Legnus
Legnus

Reputation: 159

presentModalViewController is not working on device iOs 4.0.1 jailbroken

I am trying to present a modelViewController, it works perfectly on iOs 5 device and Simulator, on iOs 4.3 simulator but it does not work on iOs 4.0.1 jailbroken device. I try to debug my code, the viewController is initialize but the method viewWillAppear is not being called on my device with iOs 4.0.1 jailbroken.It is being called on all other devices. here is my code

loadingView=[[UpdatingVc alloc]initWithVar:var1 andVars:var2 andVarz:var3]; 
[self presentModalViewController:loadingView animated:YES];

I hided the original var names with the main varNames for security reasons. the init Method is :

-(id)initWithVar:(NSString*)var andVars:(NSString *)vor andVarz:(NSString *)vers{
self = [super initWithNibName:@"UpdatingVc" bundle:[NSBundle mainBundle]];
if(self) //good practice to check first
{ 
   _a=var;
   _b=vor;
   _c=vers;
} 
return self;
}

Thank you

Upvotes: 0

Views: 321

Answers (2)

Legnus
Legnus

Reputation: 159

I found the problem, i was presenting ModalViewController inside the methode viewDidAppear, so the solution was to create a method : -(void)update and inside this method put the code of the presenting modalViewController, and then add a selector to this method in the viewDidAppear instead of calling it immediatly. So my code now is

-(void) viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    [self performSelector:@selector(update) withObject:nil afterDelay:1];
}
-(void)update{
   loadingView=[[UpdatingVc alloc]initWithVar:var1 andVars:var2 andVarz:var3]; 
   [self presentModalViewController:loadingView animated:YES];
}

note that this problem only occurred in iOs 4 on device and not on simulator with iOs 4.0

Upvotes: 0

GracelessROB
GracelessROB

Reputation: 1048

I believe your init method should be

-(id)initWithVar:(NSString*)var andVars:(NSString *)vor andVarz:(NSString *)vers{
self = [super initWithNibName:@"UpdatingVc" bundle:[NSBundle mainBundle]];
if(self) //good practice to check first
{ 
   _a=var;
   _b=vor;
   _c=vers;
} 
return self;
}

note the self= part in front of the super's init method, you need to set the value of self in an init method.

Hopefully that helps!

Upvotes: 1

Related Questions