uitableview - iOS - Tabbed aplication with table view and subview -
i have 1 problem. in app (it tabbed style), have 1 viewcontroller text , sec table view (rss reader). when have rss , set single view app, subview form rss works, when set tabbed app , click post in table view, subview didnt show up... can help me please?
here codes:
appdelegate.h
#import <uikit/uikit.h> @interface mwfeedparserappdelegate : nsobject <uiapplicationdelegate> { uiwindow *window; uinavigationcontroller *navigationcontroller; } @property (nonatomic, retain) iboutlet uiwindow *window; @property (nonatomic, retain) iboutlet uinavigationcontroller *navigationcontroller; @end
appdelegate.m
#import "mwfeedparserappdelegate.h" #import "viewcontroller1.h" #import "rootviewcontroller.h" @implementation mwfeedparserappdelegate @synthesize window; @synthesize navigationcontroller; #pragma mark - #pragma mark application lifecycle - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // override point customization after app launch uitabbarcontroller *tbc = [[uitabbarcontroller alloc]init]; viewcontroller1 *vc1 = [[viewcontroller1 alloc]init]; rootviewcontroller *vc2 = [[rootviewcontroller alloc]init]; [vc1.tabbaritem settitle:@"tab1"]; [vc2.tabbaritem settitle:@"tab2"]; [tbc setviewcontrollers:[nsarray arraywithobjects:vc1, vc2, nil]]; [window addsubview:[navigationcontroller view]]; [window makekeyandvisible]; [window setrootviewcontroller:tbc]; homecoming yes; } - (void)applicationwillterminate:(uiapplication *)application { // save info if appropriate } #pragma mark - #pragma mark memory management - (void)dealloc { [navigationcontroller release]; [window release]; [super dealloc]; } @end
from dealloc, see not using arc. have memory leaks; sure release vc1
, vc2
in didfinishlaunchingwithoptions
, tab bar controller retain them.
you don't need navigationcontroller
property, recommend delete until know you'll need it.
i think you'll want add together rss view (vc2?) nav controller before adding tab bar controller this:
[tbc setviewcontrollers:[nsarray arraywithobjects:vc1, [[[uinavigationcontroller alloc] initwithrootviewcontroller:vc2] autorelease], nil]];
and delete line:
[window addsubview:[navigationcontroller view]];
best of luck!!
edit spelled out tad more:
viewcontroller1 *vc1 = [[[viewcontroller1 alloc] init] autorelease]; rootviewcontroller *vc2 = [[[rootviewcontroller alloc] init] autorelease]; uinavigationcontroller *navcontroller = [[[uinavigationcontroller alloc] initwithrootviewcontroller:vc2] autorelease]; uitabbarcontroller *tbc = [[[uitabbarcontroller alloc] init] autorelease]; [tbc setviewcontrollers:@[vc1, navcontroller]]; [window makekeyandvisible]; [window setrootviewcontroller:tbc];
uitableview subview tabbed-view
No comments:
Post a Comment