add a commenting feature to my detailViewController - ios

i'm fairly new to iOS development, i'm trying to add a commenting feature to my detailViewController but im haveing no luck i thought if i added a test area like so:
UITextView *txt = [[UITextView alloc]init];
//set frame
//add on view
[self.view addSubView:txt];
[txt release];
it would work but nope, its for image people upload and you know how it goes if someone taps the image in the tableview it navigates to the detailViewController and it does that and shows the image and the name of it the next couple of steps involve, number of likes, number of views but thats for later date but you get my drift so i'm trying to add a commenting feature to my detailViewController what am i not correctly what are the steps?

Related

Custom UITableViewCell Edit View

I've been looking over countless questions and answers here on SO, but could not find one that would provide the answer for my specific problem.
In a nutshell: I am trying to implement a custom edit view for my UITableViewCells. I would like to keep the basic "delete" and "rearrange/drag" actions (although on opposite ends than in the default implementation and with custom icons), and I would also like to add a "duplicate" action to them and one that navigates to a specific view (separate from the one when you click the cell in normal state). Something like this:
Ideally, I would like to trigger this edit mode on all cells when I toggle edit mode with a separate button, and on individual cells with a left swipe (without the drag option if it is not possible on an individual cell).
I have sub-classed UITableViewCell and was able to add a swipe recognizer that reveals a view ("cellOptionsContainer") with the 3 custom buttons on the right, all of which I was able to make work using tags and delegates, but that is most certainly not the right way to do things because I've added them to the cell's content view (not knowing any better):
// Add container to hold options buttons
cellOptionsContainer = [[UIView alloc] initWithFrame:CGRectMake(cellWidth,
0.0f,
(dataBase.sizeInteraction * 3),
dataBase.sizeInteraction)];
[self.contentView addSubview:cellOptionsContainer];
// Add edit button
UIButton *cellOptionsButton = [[UIButton alloc] initWithFrame:CGRectMake((0.0f),
0.0f,
dataBase.sizeInteraction,
dataBase.sizeInteraction)];
cellOptionsButton.tag = cellID;
[cellOptionsButton setImage:[UIImage imageNamed:#"iconEditOutlined"] forState:UIControlStateNormal];
[cellOptionsButton setShowsTouchWhenHighlighted:YES];
[cellOptionsButton setAdjustsImageWhenHighlighted:NO];
[cellOptionsButton addTarget:self action:#selector(presentEditView:) forControlEvents:UIControlEventTouchUpInside];
//[cellOptionsContainer addSubview:cellOptionsButton];
[cellOptionsContainer addSubview:cellOptionsButton];
Meanwhile, I was also able to make work the standard edit view in my UITableView delegate (rearranging and deleting both works fine), but I was unable to augment this standard edit view with the added functionality and visual customization illustrated above. I cannot even find a way to change the standard icons...
Any help would be much appreciated; although, I am looking for Objective-C answers as I do not know Swift! I am also doing everything programmatically; I do not use interface builder.

IOS/Objective-C: Display uilabelview on two lines

I am having trouble getting a uilabelview to always display on two lines. When the page first loads, the text only uses one line and is truncated. Once you load another view controller on top of it--for example an edit VC and then cancel the second VC, the label does flow to two lines which is what I want. However, I cannot get it to do first time.
Can anyone suggest what is issue? What could be different between the VC at first and then after you have shown and canceled another VC on top of it.
The label is created in storyboard. It is reference in code in viewwillappear as follows:
_myLabel.numberOfLines = 0;
NSString *nameToDisplay = _myItem.name;
[_myLabel sizeToFit];
[_myLabel setNeedsDisplay];

swipe navigation in objective-c

I want to add a second view controller to my project with a swipe navigation. Which is the easiest way?
As you can see in the picture I have these buttons in the first view, I want to add more. I also have a background picture which is not in the picture
(below), is it possible to keep it for both views? So when I swipe to the right the background should't move, only the buttons.
Also could you please explain to me how I should make it step by step, because I am new into coding and have almost no experience.
I think what you are trying to find is paging using UIScrollView. Check out this link.
Hope this helps you.
you can use the custom class called ADPageControl. Here is the reference link : https://www.cocoacontrols.com/controls/adcustompagecontrol.
And for that image you can set the common image below your container view. Please go through the link and try to implement it.
Basically you need a UIPageViewController But you have tweak a little bit. You can find a tutorial about that here
Few Points
Create PageViewController with buttons
Make each Page views background color as clear color so your background image will be shown all the time even when you swipe.
Please don't expect full code from SO
I think you trying implement something like ..look below code
its scrollview paging
// viewArray contains paging views
viewArray = [[NSMutableArray alloc] initWithObjects:self.viewOne, self.viewTwo, nil];
// adding all views as scrollview subview
for (int i = 0; i < viewArray.count; i++) {
self.scrollView.pagingEnabled = YES;
[self.scrollView addSubview:viewArray[i]];
}
// this time you need to set scrollview contentSize but in X axis ..
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * viewArray.count, self.scrollView.frame.size.height);
have a note: you can create views using storyboard or programmatically but must set the x position of views which you want to appear on swipe.. hope this helps.

Changing UIView in Parse login window unexpectedly moves text fields

I've successfully integrated the Parse.com login service to my app, but am having trouble changing the logo in the login window (PFLoginViewController). Specifically, the logo's view appears to change position after the new logo is set.
Original 'Parse' logo frame: (159,128,222,68)
New custom logo frame: (60,12,420,68)
The other big problem is that the username and password fields move up ~100 px if I use a different logo. This means that they overlap the new logo, and it all looks quite messy. Here are the coordinates of the username field in both cases.
Username field with 'Parse' logo: (60,232,420,44)
Username field with custom logo: (60,116,420,44)
I'm not sure what I'm missing, so any guidance would be terrific. Thanks for reading!
Miscellanea:
The new logo is 720x300.
For the logo substitution, I subclassed PFLoginViewController using code based on Parse's login tutorial.
I've found a workable way forward, and though I'm still on the lookout for something better, I wanted to share this solution in the meantime.
Because PFLoginViewController appears to a) reset the size and position of the original logo view right before viewDidAppear, and b) position the rest of the window elements (e.g., username field) relative to the logo's view, I stopped trying to replace the original logo altogether.
Instead, I added two subviews to the original logo's view: the first is a UIView to cover up the original logo (in case your new logo has transparency); the second is a UIImageView with the new logo. The code goes in viewWillAppear and appears to work fine. (The main downside is that the new logo ends up with the same size and position of the old logo.)
// Create a UIView to "cover up" original Parse logo
UIView *blankRect=[[UIView alloc] initWithFrame:CGRectMake(0,
0,
self.logInView.logo.frame.size.width,
self.logInView.logo.frame.size.height)];
[blankRect setBackgroundColor:self.logInView.backgroundColor];
[self.logInView.logo addSubview:blankRect];
// Add a subview with the new logo to the original logo's view
UIImageView *newLogo=[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"LoginLogoTight.png"]];
[newLogo setContentMode:UIViewContentModeScaleAspectFill];
[newLogo setFrame:CGRectMake(0,0,self.logInView.logo.frame.size.width,self.logInView.logo.frame.size.height)];
[self.logInView.logo addSubview:newLogo];
You need to create a PFLoginViewController subclass so you can custom theses view controllers. If you want to change the frame you should override and set there the new frame for "loginview.logo"
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
[self.logInView.logo setFrame:CGRectMake(60.0, 12.0, 420.0, 68.0)];
}
I found the tutorial really helpful, I hope this work for you
https://www.parse.com/tutorials/login-and-signup-views

iOS development Animating Table view custom cell content

I am working on new application and i would like to have custom table view. I need to have cell that have 2 labels 1 check box and 2 buttons. The problem i have is that 2 buttons need to be shown only if user press edit button on top. I made all this to work but i have some problem with reusable cells or something like that.
I made custom cell class so i can assign data to it.
First state is: First state on img
Then when user press edit button on top i need everyting to animate and come to right place.
I want text to animate to right to make space for button, delete button needs to come animated from left side and edit butom to come in animated from right side.
This is what i want to get after animations are done: Second state on img
I made all this to work but now i have problem that first 2 cells that will come on screen after i scroll down are not effected by my code :(
This is what i get: Third state on img
i will post my project code here and if some1 can help me with it i would be more then thrilled. I point me to right way to do this.
Code downoald: https://www.mediafire.com/?g1g6d7h33mpkyt7
and i will post some code here that i think is crucial to my problem:
for animations i use:
[cell.infoView setFrame:CGRectMake(20, CGRectGetMinY(cell.infoView.frame), CGRectGetWidth(cell.infoView.frame), CGRectGetHeight(cell.infoView.frame))];
[UIView animateWithDuration:0.4
delay:0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
[cell.infoView setFrame:CGRectMake(70, CGRectGetMinY(cell.infoView.frame), CGRectGetWidth(cell.infoView.frame), CGRectGetHeight(cell.infoView.frame))];
}
completion:nil];
for cell init i use:
CICustomCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:CellTableIdentifier];
if(cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:#"HCICustomCell" owner:nil options:nil];
cell = [nib objectAtIndex:0];
}
cell.itemName = [dwarves objectAtIndex:indexPath.row];
cell.quantity = 25.99;
for table init i use:
UITableView *tableView = (id)[self.view viewWithTag:1];
tableView.rowHeight = 60;
UINib *nib = [UINib nibWithNibName:#"HCICustomCell"
bundle:nil];
[tableView registerNib:nib forCellReuseIdentifier:CellTableIdentifier];
img: http://i270.photobucket.com/albums/jj109/lazardj/scsimg.jpg~original
EDIT:
I also tried something now. If i start my activity then scroll down a bit so i get some new cells i dont have this problem. So it must be something with creating cells or reusability of cells or something like that. I am new to ios development so i cant figure this out on my own :( so please help :) Thanks
In your cellForRow function in your tableview delegate you need to deal with the location of your labels. So every time you request a new (or reused) cell you need to check whether you are in edit mode and then set the labels frames accordingly.
It appears as you are already doing this for the buttons, as they show up in the proper place, but the labels are being re-used at their initial locations (when they were released by the tableview).
I've had a look at your project, and the problem appears to stem from using AutoLayout. The automatic constraints appear to be interfering with your view layouts. If you go to your HCICustomCell.xib file and click on the file inspector tab, you'll see a checkbox for "Use Autolayout". Uncheck this and then set the auto-resizing constraints manually for each view in the Size Inspector tab. I've uploaded a revised version of your project here.
SOLUTION:
I done some more work on this. Tried solutions you provided me but there are still times when it gets bugged so i came with my own one. I figured out that the problem is that you cant move view in cell on first init but you can show hide them. So i decided to try to make same info view on place where it needs to be when enable is on. When enable is off its hidden and when enable is on it shows up. This is what fixed my problem :) I know its not the smartest way to do things but i managed to do what i wanted and its not messing performances of application.
This is project with fixed bugs. If any1 want can use it :)
Thanks for all your time and suggestions.
Project: https://www.mediafire.com/?uhatbh8c20xu49v

Resources