Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to have the ability to allow the user to fill out a profile, almost like the notes app and then when they are done it adds it to the UITableViewCell and displays certain parts of what they filled out on the Cell..Then they can obviously repeat this action..
I am not sure where to look for a tutorial on this or what this may be called, anyone have any suggestions?
Five simple steps :
1)Design how form is gonna look like and your tableview.
2)Make the form using a sample UIviewcontroller layout your components using xib or
storyboard
3) Embed your UIViewcontroller designed in step 2 into a UINavigationViewController
This helps you to transition from your form to UITableView
4) Design your UITableViewController and put a back button on UINavigationBar to allow user to go to previous view controller.
5) Connect UIViewController to UITableViewController
-(void)submitButtonPressed:(id)sender{
UITableViewController *tvc = [[UITableViewController alloc] initWithNib:#"your view controller name"];
// pass data to UITableViewController
tvc.userdata = self.userdata;
[self.navigationController pushviewController:tvc];
}
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
passing response data from one class to another class
//i want to pass "reside:15" to another View controller.
2013-08-16 14:29:57.273 blabby[1432:1a603] Login response:{"response":"success","resid":15}
add an class
Constant.h
in constant.h
take an string like
NSString *str;
import constant class into your class and than str =your response data;
and use it into another class.
This is an NSDictionary. As with any NSObject, you can make it a property of source view controller and access it in another view controller.
Read it in detail: Coordination between View Controllers.
create a dictionary in the view controller you want to hold that data,while pushing that view controller you can take that data and use it.It is called as design patterns.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I'm using UICollectionView to generate a image gallery.I used UIImage inside the UICollectionView Cell to load the images. I need to select UICollectionView Cell by Long Press (not by single tap).
Just pick up the didSelectItemAtIndexPath delegate callback, grab the cell, and add an image as a subview.
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
YourCollectionViewCell *cell = (YourCollectionViewCell*)[collectionView cellForItemAtIndexPath:indexPath];
UIImageView *yourImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];//whichever frame you want it to appear at
yourImageView.image = [UIImage imageNamed:#"yourImageName"];//set the image
[cell.yourBaseImage addSubview:yourImageView];//or add it to whatever part of the cell you want
}
Or alternatively, just have a hidden imageView already setup inside of Storyboard. And then unhide it and set the image inside didSelectItemAtIndexPath.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have UITextField in secondViewController and a button in same view.
I want to get that UITextField text as a string to firstViewController.
Here my code.
SecondViewController.m
-(void)backToFirstView
{
NSString *str=disTxtFld.text;
FirstView *firstView=[[FirstView alloc]init];
firstView.discountStr=str;
[self.navigationController popViewControllerAnimated:YES];
}
FirstViewController.h
#property (nonatomic,strong) NSString *disStr;
FirstViewController.m
#synthesize disStr;
-(void)viewWillAppear:(BOOL)animated
{
NSLog(#"discount:%#",disStr);
}
When i`am trying to print that string in first view..it showing null value..
any suggestions...
The easiest way to do that is by using delegates. Please take a look here:
http://krodev.wordpress.com/2012/10/08/objective-c-delegates/
It's a step by step guide how to define and implement delegate.
Delegates are used to do just that what you are looking.
make a function in 1st-viewController
-(void)setStringFromSecondView:(NSStirng *)_value{
my_String=[NSString stringwithFormate:#"%#",_value];
}
and add this in header file
-(void)setStringFromSecondView:(NSStirng *)_value;
Now add a delegate variable in secondViewController
{
id delegateOfPrevious;
}
-(void)setDelegate:(id)_delegate{
delegateOfPrevious=_delegate
}
Now before Pushing Second View Controller in First viewController you have to set the delegate of FirstView Like this
secondViewController *secondView=[[secondViewController alloc] init....];
secondView.setDelegate=self;
...........
Now every Thing is set. you are one step away from success:
before popping the SecondViewController you can call this function in second view controller and it will set the value in first view controller.
[delegateOfPrevious setStringFromSecondView:textView.txt];
Do not forget to include firstViewController.h in SecondViewController.
I did this a day before for my own project and it is working fine.
Best way: Use an unwind segue in your storyboard to get back to the previous VC and pass the data along. For more info on this, watch the Storyboards WWDC session from 2012.
Other way: Use the delegate pattern. Create a protocol in your SecondViewController class called SecondViewControllerDelegate. Give it methods like "secondViewControllerDidFinish:" and "secondViewControllerDidCancel:". Have FirstViewController conform to that protocol and provide implementations for those methods. In those implementations, make sure the presented SecondViewController is dismissed. In the SecondViewController, create a delegate property of type id.
When FirstViewController presents SecondViewController, have it set itself as the SecondViewController's delegate. When SecondViewController completes whatever work that needs to be done, have them call the delegate methods and pass in the relevant data.
one best approach is declare your nsstring as global in app delegate.h synthesize it
fill it with data in second view controller then try to acess this nsstring in first view controller.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a SPObject class, which is a custom NSObject. In the viewDidLoad method of the ViewController, I am creating an instance of SPObject. There is also a button which, on clicked, creates a new SPObject.
When my app goes to the background, I want to save these SPObjects in the database. So, in the applicationDidEnterBackground method, I am getting the instance of the main ViewController using
ViewController * vc = (ViewController *)self.viewController;
I want to know how I can get a list of the current SPObjects in the next line of the above line.
If what I wanted was a list of UIViews, I could have just done,
for(UIView * subView in vc.view.subviews)
which would have returned a good list.
How can I do this?
Have an array property of your objects:
#property (nonatomic, retain) NSMutableArray *objects;
When you create new object add it to this array:
[self.objects addObject:newSPobject];
When entering background get this array:
NSMutableArray *objects = vc.objects;
Now you can do with this array whatever you like
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Since there is no pre-existing component for creating a combobox (or select box) as seen on webpages through Safari, can someone provide an example or pre-existing 3rd party component of creating one?
I don't think this is hard to do.
In a view controller you have a UITextField and a UITableView. Assign the view controller to be the delegate of the both controls, plus the data source of the table.
Implement the UITextField delegate method textField:shouldChangeCharactersInRange:replacementString: in your controller. This intercepts the changes as they are being typed in your text field. In this method, iterate through your list of possible options and store the matches in an NSMutableArray instance variable on your view controller. Then call [myTableView reloadData].
Have your table cells generated from the array of matches you previously stored.
It should be pretty straightforward and shouldn't take much code at all beyond a few delegate methods to get working.