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.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I want delete an object from my a tableView without commitEditingStyle like iOS Music App! I do not need a swipe to delete function! How to delete cells without commitEditingStyle?
Thanks
First, remove an associated item which is related to a cell in your datasource, and let's assume you are removing the sixth row in the first section.
let indexPath = NSIndexPath(forRow: 5, inSection: 0)
self.tableView.beginUpdates()
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
self.tableView.endUpdates()
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];
}
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 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 8 years ago.
Improve this question
WARNING: Using legacy cell layout due to delegate implementation of tableView:accessoryTypeForRowWithIndexPath: in <Settings: 0x250c60>. Please remove your implementation of this method and set the cell properties accessoryType and/or editingAccessoryType to move to the new cell layout behavior.
Here,
accessoryTypeForRowWithIndexPath is deprecated in iPhone OS 3.0.
Instead set like this.
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
Existed Answers - here
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.