ios,objective-c,uicollectionview,uicollectionviewcell,nsindexpath
There are many things wrong with your didSelectRow... method. The method has an indexPath parameter Your check to compare the index path is all wrong Use an array Try this: - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { NSString *segue = segues[indexPath.row]; [self performSegueWithIdentifier:segue sender:self]; } Add an instance variable for segues...
You can create a subclass of UITableViewCell, and add two properties to it @property (nonatomic) NSInteger row; @property (nonatomic) NSInteger section; then in the cellForRowAtIndexPath: method you can set these values according to the index path. and once you want to pass the row§ion info just use delegation or KVO...
ios,uitableview,swift,nsindexpath
Try indexPath.row or, if you are using sections too, try indexPath.section in addition. :)
ios,if-statement,uitabbaritem,nsindexpath
You should implement the UITabBarDelegate protocol into your ViewController, and set the UITabBar delegate to self self.tabBar.delegate = self; After that, you can implement the method tabBar:didSelectItem: - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { // Check here for the item and change tintColor accordingly // For example: if([item isEqual:[self.tabBar.items objectAtIndex:1]) {...
ios,uitableview,swift,nsindexpath
You need to implement -scrollViewWillEndDragging:withVelocity:targetContentOffset: in your table view delegate, just as in this other question here. Basically, this method allows you to tweak the position where the velocity scroll will halt. I can't help you more with code without knowing the structure of your table view (cells of variable...
ios,uitableview,swift,parse.com,nsindexpath
That is happening because in your last bit you are always asking for row 0 section 0 in parse, you will need something like this: else { let commentCell:commentTableViewCell = tableView.dequeueReusableCellWithIdentifier("commentCell") as commentTableViewCell //indexPath.row is the actual row of the table, //so you will have for table row 2 parse...
You are access the section value correctly. You are just print it the wrong way. section have type of NSInteger, which is Int in swift just change log to NSLog("Index Path Section %d", indexPath.section) It print (null) because the section value is 0. and crashed when it is 1 because...
ios8,uicollectionview,nsindexpath
in method (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath add sth like this: UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"yourCelId" forIndexPath:indexPath]; if (cell.selected) { cell.backgroundColor = [UIColor orangeColor]; } else { cell.backgroundColor = [UIColor clearColor]; } It's happens because cells are reused and you have to reset all values that could be changed....
After a lot of playing around with this, I really wanted this to be a polished & fluid look, I've found a better solution as opposed to jn_pdx. Although his answer was resourceful and in the right direction, I did try it that way, and created CGRects for the sections...
You can do NSArray *selectedCells = [self.storeTableView indexPathsForSelectedRows]; NSIndexPath *firstIndexPath = [selectedCells objectAtIndex:0]; NSUInteger row = firstIndexPath.row and row will be 4 in your case....
swift,button,touch,nsindexpath
giorashc almost had it with his answer, but there was one more line of code that was required. The correct answer would be: let button = sender as! UIButton let view = button.superview! let cell = view.superview as! <Your custom cell name here> let indexPath = itemTable.indexPathForCell(cell) This is because...
swift,functional-programming,nsindexpath
A possible solution (written in Swift 2): let indexPaths = categories?.enumerate().flatMap() { (section, aCategory) in aCategory.videos.enumerate().filter() { (_, aVideo) in aVideo == video }.map { (row, _) in NSIndexPath(forRow: row, inSection: section) } } ?? [] indexPaths is an array of all matching index paths (or an empty array). If...
What I don't understand how NSIndexPath works. For iOS, you can think of NSIndexPath as a read-only structure that contains two Int properties section and row if you're working with UITableViews or section and item if you're working with UICollectionViews. You create them with the NSIndexPath:forRow:inSection: factory method: let...
ios,swift,uicollectionviewcell,nsindexpath,textlabel
cellForItemAtIndexPath is called for each item when it is to be displayed. You are applying some sort of a "shuffle" on the array of string? So, not all strings will necessarily be used and a few will be have same text. You can simply have the variables 'definitions' and 'boats'...
ios,uitableview,swift,nsindexpath
You can create an NSIndexPath using the row and section number then reload it like so: var indexPath = NSIndexPath(forRow: rowNumber, inSection: 0) self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Top) In this example, I've assumed that your table only has one section (i.e. 0) but you may change that value accordingly....
ios,xcode,uicollectionview,nsindexpath
Use (indexpath.section*yourTotalColumn)+indexPath.row to calculate exact index of array for UICollectionView. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { ...................... ....................... //Now calculate index of array (datasource) Note : here column is 2. NSInteger index = (indexpath.section*2)+indexPath.row cell.label.text = [textos objectAtIndex:index]; return cell; }...
You need to import UIKit. section, row and item are properties of NSIndexPath added by UIKit. https://developer.apple.com/library/prerelease/ios//documentation/UIKit/Reference/NSIndexPath_UIKitAdditions/index.html...
ios,objective-c,uicollectionview,nsindexpath
The indexPathsForSelectedItems method name has an extra s in it, Paths not Path, which indicates that it returns an NSArray of index paths, not a single index path. Hence the solution is to change these lines NSIndexPath *indexPath = [self.collectionView indexPathsForSelectedItems]; NSIndexPath* newIndexPath = [NSIndexPath indexPathForRow:indexPath.row+1 inSection:indexPath.section]; to this NSIndexPath...
ios,objective-c,uitableview,nsindexpath,heightforrowatindexpath
The problem is there because of an error related to recycling cells in the tableView:cellForSubscribedNotificationsRowAtIndexPath: method. Changing the height of one of the cells makes this error visible. You need to add code to the default case to remove accessories and cell text that you add for RowOne and RowTwo:...
ios,objective-c,uitableview,nsindexpath
From the docs about beginUpdates: Call this method if you want subsequent insertions, deletion, and selection operations (for example, cellForRowAtIndexPath: and indexPathsForVisibleRows) to be animated simultaneously. Although you've changed the isSelectedNow boolean, you haven't actually specified any insertion, deletion, or selection operations between beginUpdates and endUpdates. So you're not actually...
ios,objective-c,uitableview,nsindexpath
With UITableView you also need to specify the section of NSIndexPath NSIndexPath* indexPath = [NSIndexPath indexPathForRow:row inSection:section]; ...
objective-c,nsindexpath,robovm
I have no experience with RoboVM. However, indexPath.section and indexPath.row are just convenience methods/properties for [indexPath indexAtPosition:0] // section [indexPath indexAtPosition:1] // row and the indexAtPosition: method is defined in the Java class....
ios,xcode,swift,uitableview,nsindexpath
You can create integer variable inside you view controller, and use it as a counter -> that is, when user taps increment it and if you have enough taps perform a segue or anything else. For instance: var tapCounter = 0 as a declaration in your view controller. func tapGestureForElement(gest:UIGestureRecognizer){...
ios,objective-c,uikit,uicollectionview,nsindexpath
The answer is very simple and yet unsatisfactory for you maybe. It can't be done like that. The indexPath is created by the collectionView and not by yourself. Since the collectionView has no attribute column, you can't use it. However what you can do is calculate the column value based...
ios,objective-c,uitableview,nsindexpath
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ // create custom header here // set up a button method [yourButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; // set the button tag as section yourButton.tag = section; return yourCustomHeaderWithButton; } later -(void)buttonAction:(id)sender{ UIButton *clickedButton = (UIButton*)sender; NSLog(@"section : %i",clickedButton.tag); } ...
ios,objective-c,nsarray,nspredicate,nsindexpath
NSPredicate is just a predicate and nothing more. It is applied to some object and yields YES or NO. A predicate can be used for filtering an array, but since the predicate itself is applied to each single array element, it does not "know" the location (or index) of the...
ios,objective-c,uicollectionview,nsindexpath
You only configure the cell if it doesn't have the message UIView (tag 2) - so when cells are reused you are simply returning them as they were configured previously - however there is no guarantee that the cell be reused in the same indexPath as it was previously -...
ios,didselectrowatindexpath,nsindexpath
If you need to play the next track from your array, you need to keep track the current playing track and that index. You can do it like: - (IBAction)nextPressd:(id)sender { self.selectedTrackRow += 1; self.nextTrack = self.SPTrackList[self.selectedTrackRow]; [self playTrack:self.nextTrack]; } ...
ios,objective-c,uitableview,nsmutablearray,nsindexpath
The error message is saying you are trying to call name method on NSString. This means you have an athlete that is NSString instead of Athlete. You can check the object type in debugger or use NSLog("%@ - %@", [athlete class], athlete) to log it....
As stated in the documentation, cellForRowAtIndexPath returns: An object representing a cell of the table, or nil if the cell is not visible or indexPath is out of range. Hence, unless your table is fully displayed, there are some off screen rows for which that method returns nil. The reason...