i have a little problem on my view.
I have a uiviewControler, load a xib.
on this view i have a UIButton ( on touch it's work fine)
I add a subview create by code (on a different class )
this view respond to her touch event.
when i add this subview on my view, the event on this view are ok, but the UIButton on my first uiview not work.
I have make an error ?
EDIT :
i have make some tests.
my uiview is not really load alone. in fact i load a new uiviewController, and add it's subview to my current uiviewController.
And my problem it's due to the transparence of my new uiviewController was intercep my touch event.
If the subview's area overlaps the button it will prevent it from working. If the subview is displayed modally it will prevent the button from working. Otherwise, the button should work fine.
Your problem is most likely somewhere else.
I have change my structure code, mow my view is only manage by his class ( herited from uiview ) and i have no uiViewController just for manage this.
On the apple documentation they say the uiview controller is for manage multiple uiview on windows, and in my old code not respect this.
Related
I am looking at Apple's Date Cell (Date Cell Link) example project and I have a question about the Scene Dock in MyTableViewController. How come there are items extra items in the scene (Like Picker and Done) that are next to First Responder, Exit, and My Table View Controller? How can this be done? Also, how is this helpful?
This image shows the Scene Dock that I am referring to. Don't mind the titles, I renamed the project.
This image shows the Scene Outline for MyTableViewController, where the Picker and Done Button are shown next to the My Table View Controller, First Responder, and Exit and not within My Table View Controller.
This image shows an expanded outline for My Table View Controller where the Picker object is found also. But not Done Button is nowhere to be found inside My Table View Controller.
This image shows the code to connect to Picker and Done Button There is nothing special to this.
When I delete UIDatePicker in the scene of the controller (not in the cell), the inline DatePicker still works.
I think this sample is meant to support iOS 6.1 or earlier, to reveal the UIDatePicker as an external slide-in view, so it needs to be in the controller for IBOutlet connection.
Hope this will help.
Normally, the MyTableViewController should not be of type UITableViewController but its superclass UIViewController. This is normally necessary because UITableViewController has by definition its main view property set to the table view. It is then difficult to place other views into this view.
With a UIViewController, however, you can add any number of views. This is necessary in this case to accommodate the button and picker. The table view controller functionality can still be achieved by manually adding the UITableViewDataSource and UITableViewDelegate protocols and overriding the appropriate methods.
However, Apple here shows that it is possible by placing the other views on the same level as the main view, the table view. This is admittedly quite confusing. I usually prefer adding non-standard views as subviews to the view of a plain UIViewController.
You can drag things like picker views from the library to the scene dock to add them there.
As to the utility of doing this, I have no idea what that would be.
In this case I think that the picker and done button are left over from the writers of the code experimenting with ideas and forgetting to delete them. To verify that just delete the picker view and done button and see if everything still works.
I have a situation here which I am trying to resolve, but it seams I am missing something.
My architecture of the application is as following:
AppDelegate (TabBarController)
Navigation Controller
Viewcontroller one
Viewcontroller two
Viewcontroller three
Viewcontroller
Since I have lot of text validations and scrolling enabled, I am using a custom uiscrollview for viewcontroller one, two and three. In the custom uiscollview I am utilizing the code from Apple which causes scrollview to scroll if the textfield is being hidden behind the keyboard. The problem which I am occuring at this point is that I have the viewcontroller one working fine, but when it comes to viewcontroller two and three, it does see's that custom view controller after debugging, and reaches the point of "setContentOffSet" but not animating the scrollview, but just displaying the keyboard.
If anyone had this issue before, I would like to see what might I be missing here?
I have a tab bar app that works. Each tab is a UINavigationController whose root view is some kind of UIViewController, often a UITableViewController.
There are instances in the app where I want to display a full-screen "veil" with a message about what's happening until some operation completes. The point is to swallow up any touches on the UI that would navigate away from where the operation started.
The veil is a UIView subclass. There is one singleton instance of the class. When displayed, I insert it as a subview of the UITabBarController view. The view appears over the entire UI, tab bar included. Great!
Here's the problem. I can tap the tabs and the UI changes. What I would have expected is that my veil view would have just swallowed up the touches.
I have implemented in my veil class the various touches{Began|Ended|Moved|Canceled} methods (as do-nothing methods), but the touches are still picked up by the tab bar, and frankly by any object under whereever I happen to touch.
I've also tried overriding a number of other methods including nextResponder, hitTest:withEvent:, etc, to no avail.
I am a little stumped at this point. I'm hoping someone will have some sage advise. :-)
Thanks.
It's not safe to modify the view hierarchy of framework classes. You would be much better-served simply adding it as a subview of the window itself. As for consuming touches, if making this change doesn't work, then you should also verify that userInteractionEnabled is set to YES on the view. You should not have to actually implement any touch-related methods.
I also had this problem and came up with a hacky solution. In the init of your custom UIView class, create a dummy UIView that's impossible to hit, for example [[UIView alloc] initWithFrame:CGRectMake(-1, -1, 0, 0)]. Or actually, I think any UIView not attached to the window works. Then, in hitTest:withEvent:, have it return the dummy view for every point not in your area of interest.
I have an application , that has one mainviewcontroller with some button.When i click setting button in my application , i have added onesubview to MainView ([self.view addSubview:SettingSubView];)
Its work fine.subview frame width=200 and height=200.That subviews shows front of the mainview with center place adjusted.What i want is when subview is added to mainview, that time i dont want user interaction with mainview.Thats trick should be done in UIAlertView.When alertview is shown we cant able to touch anything in the mainview.i want to do same thing using subview.
One more thing is i dont want to add this subview as alert subview.
Is it possible ?
thanks in advance.......
Instead of making your SettingSubview a direct subviews of the main view, place a view in-between. This view should cover the entire main view and have a transparent (clearColor) background color.
Main view
-transparent view
--SettingSubview view
Try using UIActionSheet that would do, as i have done the same for one of my app
I added the reachability.m and .h files. When theres no internet connection, i want to display a UIView which is semi transparent and and comes up at the bottem like a Toolbar saying No internet Connection Available
I've got the code etc.. but i need a way to display the UIView i created and to push it to the front of everything when im using NAvigationControllers to control my application.
Could someone assist? Just need a way to push the UIView to the front but keep the nav controller on its current view so it can still go back and forth, the UIView is just a little transparant at the bottem like a pop up warning of no internet connection.
Thanks
You want the view to float above all other views but not respond to user input. You could make a new UIWindow to put the UIView in. Set the windowLevel of the window high enough to order it above other windows. Or you could add the view to the superview or window of the navigation controller.
[theNavController.view.window addSubview:theMessageView];
You could add it directly to the navigation controller view, but I think that is discouraged.