SplitView Pass from Master to Detail Issue
- Get link
- X
- Other Apps
i trying convert ipad app using tab bar controller root view using split view controller it. code in appdelegate.h is:
the .m is:code:@class rootviewipad; @class webviewcontroller2; @interface appdelegate : nsobject <uiapplicationdelegate, uisplitviewcontrollerdelegate> { uiwindow *window; uisplitviewcontroller *splitviewcontroller; } @property (nonatomic, retain) iboutlet uiwindow *window; @property (nonatomic, retain) iboutlet uisplitviewcontroller *splitviewcontroller; @end
i use ib set up, , added splitviewcontroller in mainwindow, , connected appdelegate connection splitviewcontroller splitviewcontroller added. under navigation controller in splitviewcontroller set root view rootviewipad (the tableview parses blog , shows articles), , set other view controller class , nib webviewcontroller2 articles display once clicked on. when run app, compiles, , can see webviewcontroller2 built in ib, , when rotate, left hand side tableview created. however, can't figure out how load url in webviewcontroller2. have tried either nothing, or merely pushes on master side of controller.code:#import "appdelegate.h" #import "webviewcontroller2.h" @implementation appdelegate @synthesize window; @synthesize splitviewcontroller; - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { self.window.rootviewcontroller = self.splitviewcontroller; [self.window makekeyandvisible]; return yes; }
any suggestions?code:- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { webviewcontroller2 *detailviewcontroller = self.webviewcontroller2; detailviewcontroller.webview.scalespagetofit = no; rssentry *entry = [_allentries objectatindex:indexpath.row]; [detailviewcontroller.webview loadhtmlstring:entry.articleimage baseurl:[nsurl urlwithstring:nil]]; } }
try grabbing viewcontroller attached detailview storyboard, instead of making new instance.
from there you'll need method on view controller accepts new data drives view , whats needed cause view redraw around view. haven't used web views not sure if method exists.code:- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { webviewcontroller2 *detailviewcontroller = (webveiwcontroller2 *) [[self.splitviewcontroller.viewcontrollers lastobject] topviewcontroller]; // .... // pass data object selected row detail view. [detailviewcontroller setdetailitem:[yourdatasource objectatindexpath:indexpath]]; }
Forums iPhone, iPad, and iPod Touch iOS Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
- Get link
- X
- Other Apps
Comments
Post a Comment