UIPicker and Text and URL - xcode

I'm trying to build an app that will display stats for a certain game (I'd rather not say which one). I have most of the app completed, but I have run into a problem with my "Players" page, which is the primary view that loads after viewDidLoad. I've attached a screenshot of how it looks.
(DARN IT. I'm too new to post a pic. Available on request.)
It took some work, but I finally got my UIPickerView into place, and customized the initial options for it. You can't tell from the screenshot, but the picker loads with my player name, and one other. This will change before release.
My problem is that I want users to be able to enter their gamer name(s) in a text field, and have them always selectable from the picker after that. When they select a name in the picker, I need that action to send a string, a URL, with the player name appended to it, to every other view so that all navigation subsequent to choosing a player will show that player's data. This will allow me to load the rest of my server side graphics with ease.
Also, player names must be removable from the picker.
I'm not so lazy as to simply ask for the code, but I can't seem to figure out what components to use, or even find a tutorial that speaks to what I'm doing precisely.

OK what i understand is you want to do two operations on the picker value select.
send the url with the player name.
delete the player name..(if user wants).
Now for this you can add two buttons and as you know the value that are shown in the picker is basically you can store them in am array and load it again on picker.
so now you added two buttons one is for sending data and other is for delete.
on sendData button you can do like this to select the value from picker
NSInteger row;
NSArray *repeatPickerData;
UIPickerView *repeatPickerView; //this your picker, if you defined it already dont do it.
row = [repeatPickerView selectedRowInComponent:0];
self.strPrintRepeat = [repeatPickerData objectAtIndex:row];
now in the "strPrintRepeat" you have the selected value. you can do what ever you want with it.
and on deleting the player name..you can do something like this.
NSInteger row;
NSMutableArray *repeatPickerData; //this should be mutable
UIPickerView *repeatPickerView; //this your picker, if you defined it already dont do it.
row = [repeatPickerView selectedRowInComponent:0];
[repeatePickerData removeObjectAtIndex:row];
now at this point you have the player name removed.
Then you can use your UiPicker delegates to reload the picker with the updated data..
Hope that works..:) enjoy

Related

titanium functionality

I'm new to titanium and I,m trying to build some prototypes based on wireframes. Below is the wireframe that I'm trying to build as prototype.
What you see is a list of restaurants fetched from google places api. The main functionality here is the black strip which will be at a fixed position and holds the details of rating and reviews on a particular restaurant which is underneath it.
So if I scroll through the restaurants the black strip should get the rating details of that particular restaurant which is underneath it.
So far I was able to crawl the restaurants data from google places api into row of the table view.
I'm not sure what to call this functionality or how to achieve this.
Can you guys please give me direction to proceed ahead...
#Sarat,
I assume you wanted to develop this Prototype for iOS or Android App, so using Titanium I've below suggestion for design & functionality
To Achieve Design:
For Android - Use Relative Layout with List view which you can load Rating/Review Icons on top with Fixed Position
For iOS/iPhone - Add Parent VIEW and then Add Table VIEW to load Restaurant and Add Rating/Review Icons in Another Table VIEW with Same Top position of Restaurant List
To Achieve Functionality:
You will get First cell index of Table View in which Restaurant List you're loading, so keep check which Cell of Table is on Top of Table view using Cell Identifier.
Wouldn't it be much easier to just include it as a part of the row? Otherwise the user can only see one rows information at a time, which I would consider bad design.
More importantly, this will not work on iOS unless you add a lot of dummy table rows at the end of the TableView, since the user wont be able to scroll the bottom-most row to the top of the screen!
This tutorial shows you how to have custom table rows. Use it as a starting point to add your comment and like button images. I really see no other alternative, since your fixed position method requires hacking the TableView component or using transforms to move the bottom row to the top.
EDIT:
If you must do it this way, the best way forward would be to add a number of blank table rows to past the end of your real table rows so that the user can scroll all the way down to the last row with content (this way the fixed position can detect its over it).
Next create your view holding the three buttons, making sure its absolutely position in the window (so it stays fixed) and has a zIndex greater than the TableView:
var likeAndCommentHolderView = Ti.UI.createView({
top : 45,
left : 0,
//.... etc
zIndex : 101
});
window.add(likeCommentHolderView);
Now you have to figure out which row the user is over. This can be done using the scrollEnd event of a TableView and getting the contentOffset attribute of the event. The 'scrollEnd' event is triggered when the user has finished scrolling the rows in a tableView, it returns an event that has the contentOffset, which is just a measure of how much you have scrolled from the top of the tableView. Using simple math, calculate the offset divided by the rowHeight and that is the row index the user is looking at.
// Assume table view is at coordinates : top=45, left=0 and you have defined rowHeight
tableView.addEventListener('scrollEnd', function(e) {
// Use this to determine which row your over
var contentOffset = e.contentOffset;
// Figure out the index
var rowIndex = contentOffset / rowHeight;
// Get the row, assume first section
var section = tableView.data[0];
var rowObject = section.rows[rowIndex];
// Now update your UI with data from the row
var name = rowObject.restaurantName;
});
Now you have the actual row object in the table, you can extract
This is only a general outline, this does not take into account some of the differences between platforms, I leave that to you to figure out, but this is a good general approach.

RootViewController need to resort/reload data array xcode 4.3

I'm implementing an example, in that example, I read in data from a database, put it in an array, sort it, and it's displayed using the RootViewController. The DB read and array load happen before the RVC code. So, it works, I get the data in the window created by the RVC and there's a nav controller there as well.
I want to add a button or something to the nav controller so that when you hit it, it sends a value back to the RootViewController.m file, then based on that value, I want to resort the array and display it once again in the RootViewController window.
I'm not sure how to do this. What changes would I have to make to the .xib and the RootViewController.m file?
Please, I'm a confused nube. %-0 Thank you very much.
There's a fair amount to this, so I'll give some general points and if any of them cause problems, it may be easier to work out smaller details.
In you RVC's viewDidLoad method, you can create a button and set it as the right or left button in your controller's navigationItem.
You can associate a tap on that button with a method in your controller that can do whatever you want when the button is tapped. (But a button doesn't send values, really, so you may have to explain more about that idea.)
I assume the RVC has a table view if you're showing array contents, so once the array (mutable array, I'd assume) is re-sorted, you can tell the table view to reload its data.
In answer to your secondary question, once you have resorted your array (or generally updated your data however you wish) you can force the table view to reload programmatically
[tableView reloadData];
Where 'tableView' is your instance variable pointing to your table view

How do I reset a table view?

I have a table view in an iPhone xcode tab bar application that shows data either alphabetically or numerically, depending on a user selected option in one of the tabs. It works for the most part, but when I change the option and then go back into the table view, the table view initially looks like it did before the option was changed. However, as new cells get scrolled into view, they have the new display mode.
I can identify when the option changes, but I can't seem to get the code correct that would re-initialize the cells such that the next time they come into view they have the correct values. The data comes from a static array with set values, so I don't want to do anything with the data source, just the table view.
In other words, once the display option changes, I want to wipe out the table view I have so that the next time the table view displays it will show the correct data right from the start rather than after scrolling occurs.
Any help would be appreciated. Thanks.
It sounds like you want to call reloadData on the TableView.
[yourTableView reloadData];

scrolling a readonly cell in NSTableview?

I have a table that the user should not be able to edit directly (although user actions may cause changes). One column may contain a string too long for any reasonable size cell, so to see everything there, the user needs to scroll the cell (using arrow keys, for example).
If I make either the column or cell not editible, I loose the ability to scroll the cell.
If I make it editable, of course, I loose the ability to keep the user from changeing it.
(I'm using NSArray controller and a couple of NSObject controllers to get from the model to the table view using bindings. Binding compliance via #property(copy) and #synthesize. Updating the model with setXXXX:xxx).
Thanks,
John Velman
What's wrong with letting the table display tooltips for overflowed contents? This is automatic as of 10.5 if I recall correctly, else you can use the delegate method -tableView:toolTipForCell:rect:tableColumn:row:mouseLocation: for better control.

ABPeoplePickerView - How do I get it to scroll to a selected record?

I'm using the ABPeoplePicker in a Mac OS X application. I've hooked up a button that changes the selected record to the default 'Me' record.
This works fine, and the record gets selected, but, I need to scroll the table to see the selected record.
NSTableView has the -scrollRowToVisible:(NSInteger)rowIndex method, but I can't find anything similar for the ABPeoplePickerView
There is a notification ABPeoplePickerNameSelectionDidChangeNotification that is posted when the selected record changes, but I can't find a way of plugging in a property of the record into the view so I can make it visible.
It will automatically scroll to your selection when using selectRecord:byExtendingSelection: for example:
[peopePickerView selectRecord:[[ABAddressBook sharedAddressBook] me] byExtendingSelection:NO];
Be sure you're passing NO for the byExtendingSelection argument.
PS: Previous poster is in iPhone land ;)
How about the scrollPersonToView method?

Resources