please forgive the newness level I'll be exhibiting.
I created a new iPad Master/Detail (UISplitViewController) app in Monotouch.
The master controller on the left is a UITableViewController. The detail on the right is just a UIViewConroller. These are loaded by default in the AppDelegate code.
In the master controller I then added some items to the table and overrode the RowSelected() event and that works great, so I can get the item selected. I've added an additional UIViewController (DetailViewController2) that I want to display on the right side of the screen when an item is selected in the table. It really doesn't matter which item, I just want to change the contents of the right side where the DetailViewController is to the DetailViewController2. I've tried a lot of things and nothing working -- I know this should be obvious, but I'm lost.
Thanks for any help.
If you are using UISplitViewController, the way to change the master and detail controller is to update the ViewControllers property. It always wants both, the master and the detail controller.
If you want to update the detail only, your code would be something like this:
var masterController = splitController.ViewControllers[0];
var newDetailController = new DetailViewController2();
splitController.ViewControllers = new UIViewController[] { masterController, newDetailController };
For Documentation see here:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UISplitViewController_class/Reference/Reference.html
Related
I have a simple WebView application. In one of the cases, I show a file, to allow user go back a UINavigationBar is shown:
navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 20, 320, 44)];
navigationItem = [[UINavigationItem alloc] init];
navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Back"
style:UIBarButtonItemStyleBordered
target:self
action:#selector(buttonClicked:)];;
[navigationBar pushNavigationItem:navigationItem animated:YES];
[self.view addSubview:navigationBar];
This is working nice. It shows a back button, and when back button is clicked it executes selector (button style must be improved, but I'm newbie with xCode and c# and this will come later).
In the selector i load previous url, but I can't figure out how to hide button and bar.
- (IBAction) buttonClicked:(id)sender {
return [self.webView loadRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString: lastURL]]];
}
I've tried several things, like removeFromSuperView:
[navigationBar removeFromSuperview];
Hide it:
[self.navigationController setNavigationBarHidden:YES animated:YES];
self.navigationController.navigationBar.hidden = YES;
// or
[navigationItem hidesBackButton];
// or
navigationBar.hidden = TRUE;
Using the selector (id):
[sender show:NO];
Using the alpha property:
navigationBar.alpha = 0,0;
Free memory space:
navigationItem.dealloc;
But nothing works... I think I'm missing some important detail, because I don't know really how xCode works...
Any help will be appreciated!
Personally, I would never add a navigation bar like that, but rather have a root navigation controller, which has a root view controller that holds a webview as it's view.
You did not make it very clear, how do you actually show the file?
Anyway, this code:
[self.navigationController setNavigationBarHidden:YES animated:YES];
is not working for you because you haven't provided your view controller with a navigation controller.
Provide one, maybe best in the main storyboard, and setup your view controller (that holds the webview) as its root view controller. To do that, open the storyboard, and drag/drop a UINavigationController to the main area. You have to tick the option "Is Initial View Controller". Note: when you did the drag/drop, a default root view controller was already provided. You can either leave that one, or provide your own, if you already had one in the storyboard. To do that, delete the linked one, and ctrl-click and drag from the Navigation Controller to the View Controller, to setup it as its Root View Controller. I've attached an image to showcase what I've described.
I am developing an app using Xamarin.iOS in C# language. My tableview retrieves list from webservice. This list contains folders and files. and folders can have also children and maybe children also have their own children..
So to display files, I use webview, its OK but for folders, what should I do? There can be many subfolders, I am thinking to use 2 tableviews and one webview
First tableview is for showing first list
Second tableview will show the folder's content, can be some subfolders and files. If the file tapped, webview will display it, if folder tapped, then I should reload the list of tablewView..
Logically its OK but what about if user push back.. How I should get back previous list, I dont want to call it from webservice again.. I am asking what can be the best model for it?
I think nobody will not reply my question. Well I would like to share my solution..
I called the tableview in the same tablewView. First of All, I entered a storyboard id for the tableview controller name is commonstoryboard so after my code is like that
var item = (profileLists[indexPath.Row] as QuickSearchProfile);
var result = search.GetQuickSearchProfile(item);
// FillTable(result);
// TableView.ReloadData();
var controller = (CommonTableView)this.Storyboard.InstantiateViewController("commonstoryboard");
var commonTableView = new CommonTableView(controller.Handle);
commonTableView.profileLists.AddRange(result);
NavigationController.PushViewController(commonTableView, true);
so everything works how i want. I can go many subfolders and can back (previous views still have the old values, so in this case,i do not need to call again any list from web service) I really didnt expect that kind of solution but it became perfect !!
In My app, i use an altered Example of the ViewPagerIndicator, which launches 5 Fragments. so far all works well, but the fragments do have to change their View (completly new layout) for other purposes. how do i do that? a Fragment doesn't have a function SetContentView like activities do. so is there a way to update the view or something like that?
Use Fragment.getView() to get the root view of the Fragment. On that View, call removeAllViews(). Then build your new views and add them to the view you got from getView().
Edit
I never used Mono for Android before, but looking at the documentation; I suggest you put the inflated View from inflater.Inflate in a private member of your Fragment. Later on, when needed, you can use that reference to edit your layout.
MonoTouch is 5.2.12. iOS is v5.1.1 (Simulator)
Seems like I'm missing an important piece of a puzzle here.
I'm subclassing DialogViewController and set it as the only controller in my UINavigationController.
In ViewWillAppear of the subclassed DialogViewController, I'm trying to set the left and right bar button items:
this.NavigationController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, this.HandleDoneButtonTouched );
Neither one of them is showing up. The title however is displayed. If I debug, I can see that the items are properly set.
I have also tried to use SetItems() on the navigation controller: no effects either.
The navigation controller is presented modally in a page sheet.
Navigation items are not usually updated through the navigation controller. Instead, they are updated via the NavigationItem property on the view controller:
this.NavigationItem.SetRightBarButtonItem(
new UIBarButtonItem(UIImage.FromFile("some_image.png")
, UIBarButtonItemStyle.Plain
, (sender,args) => {
// button was clicked
})
, true);
http://docs.xamarin.com/ios/recipes/Content_Controls/Navigation_Controller/Add_a_Nav_Bar_Right_Button
I need to pre-populate a list form (the add new item form for a list)
with some details (the logged in users name and email address)
how can i do it?
2 options:
create your own custom form with controls.
create a tiny weppart that does nothing else but render user info in javascript. then use jquery to get that info in the fields in the form.
I'm doing the same thing, trying to populate a people picker field.
I'm not done yet, but I was able to implement a CEWP (Custom Editor Web Part) in the form, adding:
?PageView=Shared&ToolPaneView=2
at the end of the URL of the new form. Example:
NewForm.aspx?RootFolder=.....default.aspx**&PageView=Shared&ToolPaneView=2**
After that,I put JQuery in the Web Part content, until now I trying to implement SPFF, but is kinda hard because there are not too many examples... by the time I'm done I would be pleased to help you