Changing id of a dataProvider in Flashbuilder - actionscript

I'm using Flashbuilder for this. I have a button that changes the id of a dataProvider like this:
result.datagrid.dataProvider="lineup_1";
However, I have another button which should also change the id of the dataprovider when clicked on, but to this:
result.datagrid.dataProvider="lineup_2";
However, it only responds to the first button pressed on. After that, the id stays the same, which is logic. But I need to know how I can change the id after a button is pressed too.

If you say
result.datagrid.dataProvider="lineup_1";
you do not change dataProvider's id, you change the dataProvider. So at both actions, you change the dataProvider.
More on this, I think you need to make a refresh o your dataprovider after changing. Something like :
(result.datagrid.dataProvider as ICollectionView).refresh();

Related

viewDidLoad vs viewDidAppear - Name Label issues

I'm having this problem regarding the displaying and updating of the username label.
User id 1 - ‘Felicia’
User id 2 - ‘Sam’
(1st screen: default user is 'Felicia')
(2nd screen: when change user to 'Sam')
(3rd screen: after clicking to another screen, the username's label auto revert back to 'Felicia' when it supposed to be 'Sam')
My ideal output is that the username's label will stay as the selected user unless user is changed and also to be able to reflect the name label on the side menu bar whenever the name is updated.
In my codes, I tried adding my methods(getUserInfo() and setUserNameLabel()) in viewDidAppear and viewDidLoad, however both scenarios are not generating the output I want.
viewDidAppear
Advantages:
- Name label will reflect the update of selected user's name (User can change their name)
Disadvantages:
- Name label will revert to the user id 1’s name on side menu bar when selecting other views
viewDidLoad
Advantages:
- Name label won’t revert to the user id 1’s name on side menu bar when selecting other views
Disadvantages
- Name label won’t reflect the update of selected user's name
You need to create delegate or use NSNotificationCenter for trigger name change event in side menu viewcontroller .
Because while you create side menu so that in this class viewDidLoad or any other method called once during life cycle .
Example for do this through NSNotificationCenter.
https://stackoverflow.com/a/24756761/3901620
work around: what about viewWillAppear or viewWillLayoutsubviews
I thinks viewWillAppear or viewWillLayoutsubviews (in case you use autolayout) is what you need.
When you switch from Felicia to Sam, you must save that state to somewhere to refer when you reopen your side menu.
pseudocode code:
var selected = Felicia
if `Felicia` clicked:
selected = Felicia
if `Sam` clicked:
selected = Sam
(save selected to somewhere like NSUserDefault)
And in your side menu viewWillAppear: change the UI with selected user.
load selected (from somewhere like NSUserDefault)
if selected == `Felicia`
do UI update at main thread
if selected == `Sam`
do UI update at main thread
Take a look at UIViewController lifecycle:

How to change text's color and config text's touch action in AlertView?

I want to write a UIAlertView like this picture:
I want to write some effects in it. We call the text"click(have color)" text1, and the text remained is text2. I want to change the text1's color different from text2, and I can write some click Action so that when I click the text1, this Action will be invoked.
I know that NSAttributeString can change text's color. But I didn't find which attribute can write the click Action. There's only one attribute that I can open url. But my purpose is push a viewController under a navigation.
Create your custom UIViewController, where you can write everything that you want. Present it modally over current context.
I don't think that tricking UIAlertController is a good idea

Handling Button states

Hello I have another problem/question. I have a custom control with a button on it:
I want to delete an image from it, so I removed the reference from Attributes inspector -> Image, so now my button in designer looks like this:
But when I launch it on simulator, when I press the button (just push it, not making a click ) the image shows up! Where does it come from? Are there any button states styles in project files, where this could be written?
Because button has two references - 1 outlet and 1 action and none of those are used to add image to the button! I just don't understand where from the image gets in...
You should remove the image for both normal and selected states of the button from the attribute inspector(check stateConfig attribute).

how to enter URL in textfield like facebook and show it is valid or not

I have ipad app i want that user should enter URL in textField and it should validate and should show like facebook when we enter any url it shows some page of that web or content like that in ipad any idea how to get this i know how to validate URL but how it show it like facebook page.
Attached is the screen how i want
I think you will do this in TextView not for TextField.
Some TextView do like this:
txt_note.editable=NO;
txt_note.dataDetectorTypes=UIDataDetectorTypeAll;
This will detect all URL,Phone NO,Address,etc.
OR(Method 2):
You can also see this in TextView Property in Xib file for TextView on
Right hand side.
personally i would create a customized view to show everything. You create a class URLSnapView subclass of UIView where you can place all the elements you need. a label to show the url, one for the description, a uiimageview to show your image. you can set up everything how you like it the most.
On the textfieldshouldreturn you can place the a validation method that return a BOOL value. If the result is true, it will create an instance of your customized URLSnapView with the data from your website that you will get with your NSDataDetectorType. You can also add a UIWebView to place a small area with your website that's even viewable ;)

On 'next' or 'previous' virtual keyboard in iOS

iOS5+ shows next/prev buttons above the keyboard:
Because they change the focused element on the page, they can cause issues with my single page app's layout. The 'tab' key on normal keyboards can cause similar issues, but I can slightly change its functionality to only cycle around the inputs I want with a custom keydown event.
Is there any way to do something similar for those buttons?
I'm not really sure what your problem is.
My guess is that when you change focus with "Previous" and "next" button, something goes wrong with your design. And I'm also guessing that you click these when you are in an input (although it's pretty obvious).
When you change from an input to another (With tab key, using "previous/next"-buttons or by mouse), a blur event is triggered.
Now, you don't say what library, if any, you are using. But the fix is similar all around I would say.
if you use jQuery, do something similar to this:
//Selects all input elements, and binds a anonymous function to them. This function
//is run when the blur event is triggered, meaning when we change focus to something else
$("input").on("blur", function () { //Or live, depending on jQuery version
//Your code here, that I assume you already have
});

Resources