Objective:
To write a status and update on table as in what's app & read the content in next page .
Approach:
Class1-Design,implementation of text view,button,tableview;
Class2-Display the content after selecting the row.
Solution:
1.We need three mandatory UIelements(textview,button,table).I prefer writing it programmatically,you can use either xib or Storyboard.
2.import protocols-UItextViewDelegate,UITableViewDataSource,UITableViewDelegate.
3.since the textview's text has to posted on the table it's necessary to create an instance of NSString class to store the value.Create an instance for an NSmutable array to add the string object,so that we can post it on tableview cell.
4.I added border width and corner radius to my textView so i imported "Quartz Core Framework".if you wish to add those make sure you import quartz Core framework.
So this is what my .h file looks like
Since we have added protocols,it's mandatory to import the required methods.
UITextViewDelegate doesn't have any required methods,it only offers optional methods.for our requirement we will use [- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text] Method to return the keyboard in textview.
But tableview offers two required methods from UITableViewDataSource
Next step will be designing uielements,Make sure to return the array in Number of rows inSections method and add object for index in cell for row at index path method.
So now wen we run the program,this is how it should look like(not exactly like mine,..but something like this.LOL..)
The trick lies here:
Do the following in your post Button method:
1.remove tableview from superview;
2.Save your textview's text in an string and add that to NSMutableArray;
Add the array in the delegate methods-number of rows in section & in cell for row at index path;
And the output of the following code will look like this:
If we wish to show the contents of the cell in next page import an optional method -didselectrowat indexpathmethod;
Here,m_pCopyString is an Nsstring of Class2;
Add the following in class 2:
Conclusion:
This is just a demo to show how we can update a status like on what's app.you can further improvise if you like.
To write a status and update on table as in what's app & read the content in next page .
Approach:
Class1-Design,implementation of text view,button,tableview;
Class2-Display the content after selecting the row.
Solution:
1.We need three mandatory UIelements(textview,button,table).I prefer writing it programmatically,you can use either xib or Storyboard.
2.import protocols-UItextViewDelegate,UITableViewDataSource,UITableViewDelegate.
3.since the textview's text has to posted on the table it's necessary to create an instance of NSString class to store the value.Create an instance for an NSmutable array to add the string object,so that we can post it on tableview cell.
4.I added border width and corner radius to my textView so i imported "Quartz Core Framework".if you wish to add those make sure you import quartz Core framework.
So this is what my .h file looks like
Since we have added protocols,it's mandatory to import the required methods.
UITextViewDelegate doesn't have any required methods,it only offers optional methods.for our requirement we will use [- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text] Method to return the keyboard in textview.
But tableview offers two required methods from UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
Next step will be designing uielements,Make sure to return the array in Number of rows inSections method and add object for index in cell for row at index path method.
So now wen we run the program,this is how it should look like(not exactly like mine,..but something like this.LOL..)
The trick lies here:
Do the following in your post Button method:
1.remove tableview from superview;
2.Save your textview's text in an string and add that to NSMutableArray;
Add the array in the delegate methods-number of rows in section & in cell for row at index path;
And the output of the following code will look like this:
![]() |
Writing a status Update. |
![]() |
After KeyBoard is Disabled. |
![]() |
The Status is posted to the table. |
If we wish to show the contents of the cell in next page import an optional method -didselectrowat indexpathmethod;
Here,m_pCopyString is an Nsstring of Class2;
Add the following in class 2:
Conclusion:
This is just a demo to show how we can update a status like on what's app.you can further improvise if you like.
No comments:
Post a Comment