I build keyboard with icon or image in Button and I want to show it in TextFiled or TextView - objective-c

My keyboard built in a UIView with a button inside and I want when I press the button
the icon or image to show in a UITextField or UITextView.
Is this possible ?

Alloc image-view add image to the view and set the image-view to the text field property leftView/rightView
Example :
<textField>.leftView = <view>;

Related

How to addSubview to NSSrollView correctly?

My code:
#IBOutlet weak var scroller: NSScrollView!
var showSettingsButton = NSButton(frame: NSMakeRect(0, 860, 60, 40))
showSettingsButton.title = "Settings"
scroller.addSubview(showSettingsButton)
The button looks as intended by the scrollview keeps static, but when I scroll the ScrollView, the button just looks like this:
I want to put this button always in the down-left corner regardless of scroller's scrolling.
So which view should be the superView of this button?
It should be in your View. Put it underneath the Scroll View - Text View, but make sure it will be siblings with the Scroll View - Text View, and not a child.
If you're going to add it in code, add it like
view.addSubview(showSettingsButton)
For your requirement , you should subclass NSScrollView and override the "tile" method. There you can specify your buttons frame
When you want your Button not to scroll, why do you add it to the scroll view then?
Add it to view, the superview of scrollview. So make it a sibling of the scrollview. Just add the scrolliview first and the button next so that the button overwrites the scrollview and appears on top.
ViewController
-> View
-> ScrollView
-> TextView (and anything that you want to scroll)
-> Button
You may want to do parts of this programmatically because IB or Storyboard Editor respectivey may change the view hierarchy again by making the button a subview of your scroll view.

How to display both text title and loading icon on the middle navigation?

If user clicks the icon, refresh starts. I found this https://github.com/Just-/UINavigationItem-Loading library, but it can't display both text title and loading icon on the middle navigation.
Like this photo:
Navigation item has property named "titleView".
Crete your view as you wish with label and reloadButton and then assign titleView this view:
self.navigationItem.titleView = [self getCustomView];
UINavigationBar is kind of UIView, You can do addSubView: in that. So add UILabel & UIActivityIndicator.
Let me know if you need anymore clarification.
Refer this link for code

UIView in UITableView disappear when becomes firstResponder

In storyboard I have a UITableViewController-->UITableView-->UITableViewSecion--> with static cells
in the same UITableView I also have a UIView that holds a background image and UITextView.
A click on a button shows the UIView and set it's frame, which appears OK, but as soon as I click on the UITextView or make it firstResponder programmatically the keyboard appears and the view disappears
the code when clicking the button
self.myView.frame = CGRectMake(0, self.tableView.contentOffset.y+100, self.tableView.frame.size.width, self.tableView.frame.size.height-100);
self.myView.hidden = NO;
how can I fix this?
Can you copy paste us the code where you add the view to the tableview? Are you doing it with constraints or with frames?
The issue you are having is probably due to the fact the UITableViewControllers automatically shrink the contentSize of the UITableView they hold when the keyboard shows. If you add a UIView to your tableView with addSubview: programmatically, you might need to add a flexible bottom resize mask to make sure when the contentSize shrinks in height, your view stays attached to the top and not the bottom.
Try this on viewDidLoad:
[theViewYouAddedToTableView setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin];

Changing TextView properties in IBAction method

I'm trying to have some text in a UITextView change color (and sometimes change text) after a button press:
I have loaded a text view in ViewController with a simple string in viewDidLoad
self.answer1TextView.text = questions[1];
The above displays just fine.
There is button next to it, which triggers the following method (also in ViewController):
- (IBAction)select1ButtonTapped:(id)sender {
self.answer1TextView.textColor = [UIColor redColor];
}
The problem is this: when the button is tapped, the text in the UITextView doesn't change color, and the right half of the view disappears.
I'd greatly appreciate some advice on this. Thank you.

How can an iOS7-style "Now Playing" button be added to an UINavigationBar?

I'd like to add an iOS7 Music app style "Now Playing" button to the UINavigationBar
The button should have:
two lines of text
a right pointing chevron
How can this be achieved?
You will probably need the image for the chevron. If that's okay for you then you can create a UIButton with proper title and image insets and pass to initWithCustomView: method.
Note: you will also need to set numberOfLines = 2 for this button which as far as I know you can not do in IB