CollectionView Button action to go to another viewcontroller to display array of images - uicollectionview

I am working on collectionview, i need to display array of items in another viewcontroller through button action, i don't know how to access an array inside the button, can anyone please tell me?
Here is my code below imageenter image description here

Looks like there is a simple solution for that .. You just need to add create a variable of same type in next controller.
let dataToPass = secondImagesArray
let vc = ImageViewController()
vc.data = dataToPass
navigationController?.push(vc,true)
Give it a try. :)

Related

How can i fill my Panels with GridLayoutmanager

firstly look at https://imgur.com/a/1r6sK31
I have a project where I wanna show a Table with some data.
it show the data but the panels dont fill verticaly and horizontaly.
I use the GridLayoutManager from com.intellij.uiDesigner.core
thats how it looks right now
The table has its own panel and class where it gets its data
the class below the table is just a baseClass with all buttons (so i dont need to rewrite the class all the time) and a panel for the table, where it should be filled, and the mainView where i wanna add the tableView and fill it in the panel where it should be added. View first Image
Edit:
i add all panels with mainPanel.add(panelToAdd,new GridConstraints());
I found a solution that works.
You need to add GridConstraints and set the LayoutManager to these JPanels
GridConstraints constraints = new GridConstraints();
constraints.setFill(GridConstraints.FILL_BOTH);
this.setLayout(new GridLayoutManager(1,1));
this.add(mainPanel, constraints);

How to make button as one of the column inside table component in CDE Pentaho?

I am trying to make the table component with the button inside the table column in CDE Pentaho. How can it be achieved?
I guess it will need some work.
In the Draw function of your table, you may put some javascript to manipulate the DOM and add your button : as far as I remember, the draw function receives a parameter that is a structure with the column and row index of the current cell.
Try first this code in the draw function :
function(paramdraw) {
console.log(paramdraw);
}
and look for the content of paramdraw iin the console.
Maybe there is a better way to do it...
What we do here usually is something like editing the query on the datasource with a column that output the HTML code for a button.
SELECT
ID,
NAME,
concat('<input type="button" onclick="alert(',ID,')">click me</input>') as button
FROM
foo
WHERE
bar='bar';
That should display a button. If you are not using a query as datasource, but a transformation the idea is the same. Just make the output contains a string that when interpreted by the browser is a button.
Hope it helps. =)

Handling tableview cell selection from other view controllers

I have a tableView with custom table cells which displays a list of sayings. While selecting a cell (say "saying1") from the tableView, the cell will get selected and will moves to next view controller for showing an explanation of selected saying. In that view controller two buttons "Previous" and "Next" are there for navigating to previous and next saying. So user may select next button for seeing next saying (say "saying2"). But the problem here is, In this stage when i navigate back to my tableview, the cell selected will be "saying1" not "saying2".
In order to solve this problem, i collected the currently selected sayings ("saying2's") index from array (ie,index will be 1) and passed it to the previous tableView through segue and converted that value into NSIndexpath. After this step i don't know what to do. Please help me in solving this.
You can specifically select a cell by calling following method present in UITableView class :
selectRowAtIndexPath:animated:scrollPosition:
refere to following link : https://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/selectRowAtIndexPath:animated:scrollPosition:

how to identify which cell in tableview clicked

I created tableview that read from url (any cell has name of book) and when clicked any cell gone detailView.
in detail view exist UIScroll that read any image from url and I create it.
but my problem this place. I don't know what read images in UIScroll related any cell.
this is URL : ".../mamal/book.php?p=%d&b=%d"
(p and b display number page and number book)
I want when clicked first cell (book1) compiler gone next page and display images related book1
and etc.
You have to use UITableView protocols <UITableViewDataSource,UITableViewDelegate> in your .h file then use below delegate method which you give which cell is clicked
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(#"Clicked cell-> %d", indexPath.row);
}
You can also identify the currently selected row using the property indexPathForSelectedRow.
i.e if you want to know the index path of currently selected row at any point of time without using the delegate methods (not saving it during selection) you can use
tableView.indexPathForSelectedRow
If you want to pass around the value between multiple view controller you can declare an instance variable in the view controller you want the value to be passed and store tableView.indexPathForSelectedRow in this variable during initialization. A quick search on so should help you with that.

my DetailViewController has text field. It appears empty at my first tap after that

I have a table view which has full of items getting from my database. I open my app. I tap one of my items in table view, then DetailViewController that has only text field does not display anything it is empty. But when I go back to table view then tap any other item again , at this time it displays value what I wanted to display.. It does it for my only first tap.. I have no errors and warnings.. What am i missing?
Sounds like you implemented tableView:didDeselectRowAtIndexPath: instead of tableView:didSelectRowAtIndexPath:.