objective c - iOS: how to convert nib-involving codes to storyboard codes? -
recently started learning ios programming, , found books ios programming in objective-c. book (learning ios programming, 2013) has part demonstrates way produce table-view apps, got stuck in codes in book.
for example, book used below codes in didfinishlaunchingwithoptions of appdelegate.h implement desired table.
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // override point customization after application launch. city *london=[[city alloc] init]; london.cityname=@"london"; london.citydescription=@"the capital of united kingdom , england."; london.citypicture=[uiimage imagenamed:@"london.jpg"]; city *sanfrancisco=[[city alloc] init]; sanfrancisco.cityname=@"san francisco"; sanfrancisco.citydescription=@"the heart of san francisco bay area."; sanfrancisco.citypicture=[uiimage imagenamed:@"sanfrancisco.jpg"]; city *sydney=[[city alloc] init]; sydney.cityname=@"sydney"; sydney.citydescription=@"the largest city in australia."; sydney.citypicture=[uiimage imagenamed:@"sydney.jpg"]; city *madrid=[[city alloc] init]; madrid.cityname=@"madrid"; madrid.citydescription=@"the capital , largest city of spain."; madrid.citypicture=[uiimage imagenamed:@"madrid.jpg"]; self.cities=[[nsmutablearray alloc] initwithobjects:london,sanfrancisco,sydney,madrid, nil]; self.viewcontroller=[[viewcontroller alloc] initwithnibname:@"viewcontroller" bundle:nil]; self.window.rootviewcontroller=self.viewcontroller; [self.window makekeyandvisible]; /*uistoryboard *test=[uistoryboard storyboardwithname:@"main" bundle:nil]; self.viewcontroller=(uiviewcontroller *) [test instantiateviewcontrollerwithidentifier:@"viewcontroller"]; self.window.rootviewcontroller=self.viewcontroller; [self.window makekeyandvisible];*/ return yes; }
and codes appdelegate.h this:
#import <uikit/uikit.h> @interface appdelegate : uiresponder <uiapplicationdelegate> @property (strong, nonatomic) uiwindow *window; @property (strong, nonatomic) uiviewcontroller *viewcontroller; @property (strong, nonatomic) nsmutablearray *cities; @end
so followed illustration in book first time, app crashed , tells me "could not load nib in bundle". check similar problems here , know nib layout design replaced storyboard (i wrote codes try helping problem didn't work, check commented codes above). how convert above codes storyboard-compatible codes, "initwithnibname",so same outcome produced? have storyboard files producing layouts(my xcode 8.3.3 , cannot find ways implement nib files). thanks.
Comments
Post a Comment