ios - open a new view inside app delegate -


the app delegate.h file follows

#import <uikit/uikit.h>  @class afaviewcontroller; @class openinchromecontroller; @class afabarcodescanner;   @interface afaappdelegate : nsobject <uiapplicationdelegate,uialertviewdelegate> {      openinchromecontroller *openinchromecontroller_;     afabarcodescanner *bs;  }    @property (strong, nonatomic) uiwindow *window;  @property (strong, nonatomic)afaviewcontroller *viewcontroller;  @property(strong,nonatomic)afabarcodescanner *bs;    @end 

the app delegate.m file follows

#import "afaappdelegate.h" #import "afaviewcontroller.h" #import "openinchromecontroller.h" #import "afabarcodescanner.h"   @implementation afaappdelegate  @synthesize bs;   @synthesize window;   - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {      self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];     if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone)     {         self.viewcontroller = [[afaviewcontroller alloc] initwithnibname:@"afaviewcontroller_iphone" bundle:nil];     }      else     {         self.viewcontroller = [[afaviewcontroller alloc] initwithnibname:@"afaviewcontroller_ipad" bundle:nil];      }      self.window.rootviewcontroller = self.viewcontroller;     [self.window makekeyandvisible];     return yes; }     - (void)applicationwillresignactive:(uiapplication *)application {     // sent when application move active inactive state. can occur types of temporary interruptions (such incoming phone call or sms message) or when user quits application , begins transition background state.     // use method pause ongoing tasks, disable timers, , throttle down opengl es frame rates. games should use method pause game. }  - (void)applicationdidenterbackground:(uiapplication *)application {     // use method release shared resources, save user data, invalidate timers, , store enough application state information restore application current state in case terminated later.      // if application supports background execution, method called instead of applicationwillterminate: when user quits. }   - (void)applicationwillenterforeground:(uiapplication *)application {     // called part of transition background inactive state; here can undo many of changes made on entering background.  }   - (void)applicationdidbecomeactive:(uiapplication *)application {     // restart tasks paused (or not yet started) while application inactive. if application in background, optionally refresh user interface. }  - (void)applicationwillterminate:(uiapplication *)application {     // called when application terminate. save data if appropriate. see applicationdidenterbackground:. }  -(void)actionsheet:(uiactionsheet *)actionsheet clickedbuttonatindex:(nsinteger)buttonindex {      if (buttonindex == 0)     {         [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:                                                     @"itms-apps://itunes.apple.com/us/app/chrome/id535886823"]];      } }    - (bool)application:(uiapplication *)application openurl:(nsurl *)url sourceapplication:(nsstring *)sourceapplication annotation:(id)annotation {      uialertview *alertview;     alertview = [[uialertview alloc] initwithtitle:@"error" message:@"inside open url" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil];     [alertview show];      afabarcodescanner *vc = [[afabarcodescanner alloc] initwithnibname:@"afabarcodescanner" bundle:nil];     [self.view addsubview:vc.view];        return yes; }     @end 

i open new view inside custom url function. when request obtained external web page view inside application delegate must opened.

there couple of ways achieve it:

first: appdelegate has property window. window view, can do

[self.window addsubview:newview]; 

second: view controller can reach window without dealing app delegate.

[controller.view addsubview:overlayview]; 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -