i have created ios app. uitableview each row show on textbox. button click to move next row. default show on 10 rows. last record to scroll to another records.
here is the code
if (![self.tableView.indexPathsForVisibleRows containsObject:indexPath]) {
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition: UITableViewScrollPositionMiddle animated:YES];
self.nextRow = i;
self.nextColumn = j;
}
now scroll the table but cursor focus on last records(10). how to focus set on 11th records. here is the attachment
Try TPKeyboardAvoidingTableView class for your tableView. It will manage this by itself.
Related
My app has a banner that is made with horizontal UICollectionView.
And the data of banner get from server.
The banner has two or more count (test count was 4.).
But the VoiceOver only speaks two cell and skips remainder cells.
View Hierarchy is
ViewController > TableView > CollectionView
CollectionView in TableViewCell
- (void)setVoiceOver
{
self.isAccessibilityElement = NO;
self.collectionView.isAccessibilityElement = NO;
}
CollectionViewCell
-(void)setArr:(NSDictionary *)arr
{
_arr = arr;
[self setVoiceOver];
}
-(void)setVoiceOver
{
self.isAccessibilityElement = YES;
self.contentView.accessibilityElementsHidden = NO;
self.accessibilityLabel = [NSString stringWithFormat: "ad%d", _arr["bannerId"]];
}
I want to make VoiceOver reads all banner cells.
I guess the VoiceOver can access the collectionViewCell which is appeared in the screen.
I tested several apps, the cells that I can access with the voiceover swipe gesuture are over the screen a little bit.
like this.
enter image description here
So the voiceover have to adjust to collectionview, not the collectionviewcell.
And we can access each cell by scrolling gesture (three finger swipe)
I have a table with 7 cells (could increase in future). Only 4 cells are visible and are hittable from UI on screen1. I want to tap 7th cell go to screen2 and I am successfully able to scroll down (checking if cell is hittable and scrolling one cell at a time) and tap 7th cell but once I come back to screen1, I want to swipe all the to top at once (not scrolling one cell at a time). I tried using "swipeup" but when doing so it is tapping on the cell and I am navigated to screen2 (and test fails) which I don't want to happen.
How can I achieve this?
Thanks in advance.
code for scroll down:
int elementIndex = 0;
NSArray *cells = tableView.cells.allElementsBoundByIndex;
for(XCUIElement *cell in cells){
NSString *name = transactionCell.staticTexts[#"Name"].label;
if (!cell.hittable) {
[Testfunc scrollDown:tableView withApp:app index:elementIndex-1];
}
[cell tap];
elementIndex++;
//do stuff if this is the correct cell else go to next cell
}
+ (void) scrollDown:(XCUIElement*)tableView withApp:(XCUIApplication*)app index:(int)elemntIndex {
XCUIElementQuery* tableCells = tableView.cells;
int tableCount = (int)tableCells.count;
if(index > 0 && elemntIndex < tableCells.count-1){
XCUIElement* startElement = [tableCells elementBoundByIndex:elemntIndex];
XCUIElement* endElement = [tableCells elementBoundByIndex:elemntIndex-1];
[startElement pressForDuration:0.1 thenDragToElement:endElement];
}
}
I tried scroll all the way up by doing:
XCUIElement *elementSwipe = transactionCell.staticTexts[name];
[elementSwipe swipeUp];
But then it taps on the cell before scrolling up and I am navigated to screen2. Then test fails.
You can try to tap on your status bar like:
XCUIApplication().coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.02)).tap()
It would scroll all the way to top.
Tap on the status bar, that should scroll you to the top.
let app = XCUIApplication()
app.statusBars.element(boundBy: 0).tap()
I have the following code
if(self.roCount < 4)
{
[self.tableView scrollRectToVisible:CGRectMake(0, 50, 1, 1) animated:NO];
}
[tableView deleteRowsAtIndexPaths:#[indexPath]
withRowAnimation:UITableViewRowAnimationFade];
I need the tableview to scroll BEFORE it tries to delete the row. This is because if I get down to the last 4 rows, trying to delete it throws an exception relating to the animation not having enough room to animate due to the header I have in place.
If I change this code to scroll when self.roCount is higher so I can see if it even works, it scrolls, but not until AFTER the cell has been deleted. Shouldn't it scroll BEFORE it tries to delete the cell? Why do I not see the scroll happening until after the cell has been deleted?
When you call scrollRectToVisible: with animated set to NO, that executes immediately, but does show up on screen until the next display cycle.
To get the effect you want, you should probably scroll with animation, then after that animation completes, delete the rows.
I have an NSTableView of content type View Based with two columns.
My objects are structured as follows:
Table View
Table Column
Table Cell View
Text Field
Table Column
Table Cell View
Popup Button
For a selected row, I want to get an element inside the selected row for a specific column. Specifically, I want to get the Text Field in the first column for the selected row.
I have an outlet to the table view and I have the index of the selected row so far, but that's about it:
- (void)getSelectedTextField
{
NSInteger selected = [tableView selectedRow];
}
Any ideas on how I can go about tackling this problem?
Edit: This is what I am trying to do: I want to change the text field to be in an editing state and focus on it so the user can start editing the text field value as soon as it is selected
I seemed to have solved my own problem:
- (void)getSelectedTextField
{
NSInteger selected = [tableView selectedRow];
// Get row at specified index
NSTableCellView *selectedRow = [tableView viewAtColumn:0 row:selected makeIfNecessary:YES];
// Get row's text field
NSTextField *selectedRowTextField = [selectedRow textField];
// Focus on text field to make it auto-editable
[[self window] makeFirstResponder:selectedRowTextField];
// Set the keyboard carat to the beginning of the text field
[[selectedRowTextField currentEditor] setSelectedRange:NSMakeRange(0, 0)];
}
Use can get all element of table view cell by get its subview. Suggest show log list subview before use it
NSInteger index = [self.tableViewFiles selectedRow];
// Get row at specified index of column 0 ( We just have 1 column)
NSTableCellView *cellView = [self.tableViewFiles viewAtColumn:0 row:index makeIfNecessary:YES];
// Get row's checkBox ( at index 0, textFields is 1,2)
NSButton *checkBox = [[cellView subviews] objectAtIndex:0];
If the text field is the only subview of your table view cell, you can get a reference to it with the following code, and select its text, so it's ready for editing:
-(void)tableViewSelectionDidChange:(NSNotification *)notification {
NSInteger row = [notification.object selectedRow];
NSTextField *tf = [[[notification.object viewAtColumn:0 row:row makeIfNecessary:NO]subviews] lastObject];
[tf selectText:tf.stringValue];
}
I making an app with a table view and a data source (core data). In this table i group several tasks ordered by date, and i have this segmented control.
I want the table to only load the tasks later or equal than today's date, when the user taps the second segment i want to show all tasks, if he taps the first segment the table must only show the later dates tasks again.
The problem is:
1 - I'm using fetchedResultsController associate with a indexPath to get the managed object.
2 - I use the insertRowsAtIndexPaths:withRowAnimation: and deleteRowsAtIndexPaths:withRowAnimation: methods to make the cells appear and disappear. And this mess with my indexPaths, if i want to go to the detail view of an specific row it is associate with a different indexPath, after delete the rows.
This problem was fixed by a method i did, but i still have other problems of indexPaths and cells, and it seems to me that is gone be me messy to each problem a fix.
There is a simple way to do that?
I tried just to hide the cells instead of delete, it works just fine, but in the place of the hidden cells was a blank space, if there is a way to hide these cells and make the non-hidden cells occupy the blank space i think that will be the simplest way.
Anyone can help me?
set the height of the cell to 0 when it hides, and set the height back to the original value when it appears.
TableViewController.h
#interface TableViewController{
CGFloat cellHeight;
}
TableViewController.m
- (void)cellHeightChange{
//if you need hide the cell then
cellHeight = 0;
cellNeedHide.hidden = YES;
//if you need hide the cell then
cellHeight = 44; // 44 is an example
cellNeedHide.hidden = NO;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
switch (section) {
// for example section 0 , row 0 is the cell you wanna hide.
case 0:
switch (row) {
case 0:
return cellHeight;
}
}
}
When the user taps on a segment execute a new fetch request on your managed object to give you an appropriate array (either an array of all dates, or the greater/equal dates). Then use reloadData on the tableView using this new array in the datasource.
or
Give the cell's you wish to hide a height of 0?