Using a RTLabel, I show eficently this html string:
Example Street, 1
as: Example Street, 1. Its clickable, but no action is done. Any RTLabel user Knows how active an action?
Or if there is some altrnative to open in safari that link (in this case to show a map).
Thanks in advance
Set the RTLabel delegate as:
[rtlabel setDelegate:self];
On tapping the link, the below function gets called. Handle accordingly:
-(void)rtLabel:(id)rtLabel didSelectLinkWithURL:(NSURL*)url
{
RTLabel * label = (RTLabel*)rtLabel;
[self openBrowserViewForURL:[url absoluteString] pageTitle:label.text];
}
Related
I am trying to send a like and a retweet command to a twitter page, with cefsharp, but my tries don't work any more until now.
The like button has 'ProfileTweet-actionButton js-actionButton js-actionFavorite' as button class name.
The tweet buutton has 'ProfileTweet-actionButton js-actionButton js-actionRetweet' as classname : that opens a window with a button having 'EdgeButton EdgeButton--primary retweet-action' as class name.
string click = "document.getElementsByClassName('EdgeButton EdgeButton--primary retweet-action')[0].submit();"; //.button();"; //ProfileTweet-actionButton js-actionButton js-actionRetweet
Task<JavascriptResponse> response = browser.EvaluateScriptAsync(click);
click = "document.getElementsByClassName('ProfileTweet-actionButton js-actionButton js-actionFavorite')[0].submit();"; //.button();";
response = browser.EvaluateScriptAsync(click);
gives a {not yet computed} Task.result, and button() instead of submit() methods give the same result.
Perhaps the do-undo buttons add a layer of something, to click on them ?
Tx a lot for your tips/ideas, in all cases.
I have a button action that reads off input from a textfield when the user types something, here is the code:
-(IBAction)searchnickname:(id)sender{
[theWebView highlightAllOccurencesOfString: (#"*Nick:", searchText.text)];
}
What I need this to do, is when the user hits this button.. It puts "*Nick:" then whatever the user types after that. I need it to automatically add *Nick: before the string the user enters.
Thank you
I hope this helps:
-(IBAction)searchNickname:(id)sender {
[theWebView highlightAllOccurencesOfString: [#"*Nick:" stringByAppendingString:searchText.text]];
}
Try this...
-(IBAction)searchnickname:(id)sender{
[theWebView highlightAllOccurencesOfString:[NSString stringWithFormat:#"Nick:%#",searchText.text]];
}
I'm creating a game for iOS and need some help.
Simply put, random letters will be shown in a label(changing at regular interval), and the user must press the button when they recognise a pattern. If they press the button they earn points, and if they miss it, they lose points.
For example:
let's say they are looking for a letter repeating over one gap. They see the letters "R K W K". On the second K they would press the button. I need to be able to check if the button was pressed while that second K was displayed. I have searched here on stack overflow, but I can't really find anything specific to my situation. Thanks in advance for your responses. I'm new here, so I tried to be as specific as possible.
You can do something like this:
Make a global variable of type bool lets call it isMatch.
While displaying other letters make isMatch = false;
When you display the second 'K' (as your example) make isMatch = true
In you button click method check:
if(isMatch){
point++;
}
else point--;
Make sure you change isMatch = false on displaying other letters.
Hope this helps.. :)
As I understood you are displaying K (say) in UILabel and you might be getting input in UITextField, what you should do is implement ValueChanged IBAction for UITextField and add all letters (K, M, X, H) etc in an array what you have on screen for now. When the text changes it will come in above IBAction, match the UITextField's text with the elements of an array. If there is a match, you are done!
Hope this helps!
Just check in the selector for the button ... (If you're using Interface builder replace void with IBAction)
- (void) buttonWasPressed:(UIButton *) sender {
if ([[[sender titleLabel] text] isEqualToString:#"K"])
point ++;
else
point --;
}
try like this
- (void)buttonTapped:(UIButton *)yourbutton;
{
yourbutton.selected = ![yourbutton isSelected];
}
then this
[self.yourbutton isSelected];
I'm learning OBJ.C/Xcode/Cocoa here and have run into a question I can't seem to find an answer for.
I want the text in a UILabel to switch between two states (ON/OFF for example) each time the user clicks the same button.
I can get the label to switch to one state, but can't get it to switch "back" when the user clicks the button again. I am assuming there is some logic required, or checking the status of the object once the button is clicked...
Does this require me to keep track of a bool or the "state" of the Label (or button)?
Would this require two methods to be associated to the button, or can it happen with just one?
Thanks for any guidance/pointing in the right direction/Code snips!!!!
~Steve
I got an answer, and it works:
- (IBAction)flip:(id)sender
{
_flipButton.selected = !_flipButton.selected;
self.flipLabel.text = (_flipButton.selected) ? #"ON" : #"OFF";
}
- (IBAction)flip:(id)sender {
[yourButton setSelected:!yourButton.selected];
self.flipLabel.text = (yourButton.selected) ? #"ON" : #"OFF";
}
This toggles the selected state of the button then checks its state to determine which string to pass to the text property of your label.
the easiest way (I think) is to store a BOOL with the state of the UILabel and (on each click of the button) negate the BOOL and set the appropriate text of the Label
You could call this: yourLabel.enabled = !yourLabel.enabled on button click to change the enabled-state of your UILabel. Or what kind of state do you mean ?
I am showing an URL in my uiwebview and it is working properly.
So the web page actually contains some Javascript functions (fun1, fun2, fun3...) which is getting executed once I select some portion over webview.
So my requirement is to detect the Javascript method which is being executed on selection over webview.
So I have implemented UITapGestureRecognizer over webview.
[myWebView addGestureRecognizer:tapGestureRecognizer];
Now once I select on the webview my following method is called:
-(void)singleTap:(UIGestureRecognizer *)gestureRecognizer
{
[myWebView stringByEvaluatingJavaScriptFromString:#"function getItem(){ var functionName =arguments.callee.name; alert(functionName);}getItem()"];
}
But I am not getting the Javascript method which is executed, how can I get this?
Note : Somewhere I have read that arguments.callee.name; has been deprecated, so is that the problem?
You need to modify the JavaScript on the remote webpage to set a global variable with the currently running function's name, like so:
var CURRENT_FUNCTION = '';
function someFunction() {
CURRENT_FUNCTION = 'someFunction()';
}
Then from the iOS side you can accomplish this by changing your code to say:
NSString *currentFunction = [myWebView stringByEvaluatingJavaScriptFromString:#"return CURRENT_FUNCTION"];
Does that make sense?