Extending PageControl, stumbling over UIScrollView...

I'm trying to make something work in my app and having no luck, so I went back to the PageControl example to see if I could do it there.
At the bottom by the PageControl widget I added two buttons, one to add a page, one to remove a page.
1) If I add a page at the end it works fine. I created a handler for the add button, and basically do this:
kNumberOfPages++;
pageControl.numberOfPages = kNumberOfPages;
[pageControl updateCurrentPageDisplay];
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages, scrollView.frame.size.height);
[self changePage:self];
However, it's not quite right as the page control doesn't update on the next move left or right, but on the one after that.
I am completely unclear how to insert in the middle of the view.
2) If I delete a page what I end up with is a blank frame in the middle. That is pages to the "right" don't move left to fill in the space. And indeed, if I scroll to the right end I can see "past" the right most page to the old right most page.
It almost looks like the only way to remove something is to delete the UIScrollView and build a new one based only of the items you want. Is that true? If so it may help explain my next problem, which is I want to make the remove button work like trash in photos or mail, sucking the current page down into it. Is the solution to build a new UIScrollView behind, then suck the current one down into the trash? That sounds heavyweight.

Thanks for the very useful reply. I hadn't quite grasped what was going on in the page control demo before, but with the code you provided and the description I think I finally got it. For the archives here, this is the code you provided with minor cleanup, plus the delete page method as well. I added two buttons to the bottom of the screen, one for add, one for delete and linked them to these methods. Note that I disable the delete page button if there is only one page, and disable the add page button if we've hit the maximum number of pages.
// AppDelegate.h
@interface AppDelegate : NSObject <UIApplicationDelegate, UIScrollViewDelegate> {
IBOutlet UIButton *addPageButton;
IBOutlet UIButton *deletePageButton;
@property (nonatomic, retain) UIButton *addPageButton;
@property (nonatomic, retain) UIButton *deletePageButton;
//AppDelegate.m
static NSUInteger kNumberOfPages = 1;
static NSUInteger kMaxNumberOfPages = 6;
@implementation AppDelegate
@synthesize addPageButton, deletePageButton;
// New Code
- (IBAction)deletePage:(id)sender {
NSLog(@"AppDelegate: deletePage");
int page = pageControl.currentPage; // changed
kNumberOfPages--;
[viewControllers removeObjectAtIndex:page]; // changed
// added loop - adjust page numbers and frames of pages which have been bumped up
for (int iIndex = page; iIndex < kNumberOfPages; iIndex++) {
MyViewController *controller = [viewControllers objectAtIndex:iIndex];
if ((NSNull *)controller == [NSNull null])
continue;
[controller resetPageNumberTo:iIndex];
if (nil != controller.view.superview) {
// the attached view needs to be relocated before scrolling begins
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * iIndex;
frame.origin.y = 0;
controller.view.frame = frame;
NSLog(@"     page %d, origin.x=%3.0f", iIndex, controller.view.frame.origin.x);
pageControl.numberOfPages = kNumberOfPages;
if (kNumberOfPages == 1) {
deletePageButton.enabled = NO;
addPageButton.enabled = YES;
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages,
scrollView.frame.size.height);
pageControl.currentPage = page - 1; // added line
[self changePage:self];
- (IBAction)addPage:(id)sender {
NSLog(@"AppDelegate: addPage");
int page = pageControl.currentPage + 1; // added line
kNumberOfPages++;
[viewControllers insertObject:[NSNull null] atIndex:page]; // added line
// added loop - adjust page numbers and frames of pages which have been bumped up
for (int iIndex = page + 1; iIndex < kNumberOfPages; iIndex++) {
MyViewController *controller = [viewControllers objectAtIndex:iIndex];
if ((NSNull *)controller == [NSNull null])
continue;
[controller resetPageNumberTo:iIndex];
if (nil != controller.view.superview) {
// the attached view needs to be relocated before scrolling begins
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * iIndex;
frame.origin.y = 0;
controller.view.frame = frame;
NSLog(@"     page %d, origin.x=%3.0f", iIndex, controller.view.frame.origin.x);
pageControl.numberOfPages = kNumberOfPages;
if (kNumberOfPages == kMaxNumberOfPages) {
addPageButton.enabled = NO;
deletePageButton.enabled = YES;
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages,
scrollView.frame.size.height);
pageControl.currentPage = page; // added line
[self changePage:self];
And of course, we still need the update in MyViewController to make this example complete...
@implemention MyViewController
// added to support page insertion and deletion
- (void)resetPageNumberTo:(int)page {
pageNumber = page;
pageNumberLabel.text = [NSString stringWithFormat:@"Page %d", pageNumber + 1];
self.view.backgroundColor = [MyViewController pageControlColorWithIndex:pageNumber];
With all that working well, I have one more request. I would like to animate the page addition and removal to make it more obvious what is going on. On page removal, I would like to make it work like the trash can in the Photos app, or the trash can in mail. That sort of suck the page down into the icon animation. I'm not quite sure what adding a new one should look like. Any tips on how to make those animations work?

Similar Messages

  • CS6 does not open after EXTENDED trial is over

    Hello everybody , I bought last september Photoshop CS6 on CD . Lately an EXTENDED trial version installed itself without my full consent ! now over one month later when I ask for CS6 Adobe Manager tell me to activate, if I try to connect it will not do it the wheel keeps turning (anyway I do not want EXTENDED) and I cannot even open CS6 !  (My serial number is already registered on my Adobe account) . What should I do ? - I am on Macbook) ? Thanks GB

    Thanks everybody for all the information. Finally, after few hours of work :-) I solved my problem by uninstalling everything regarding CS6 from the macbook, cleaning it with Onyx, reinstalling CS6 from the original DVD. Then I could open CS6 which said approximatively "EXTENDED version is out, you are back to CS6 standard" BUT it said also " you have a 7 days trial, you have to activate CS6 during these 7 days" !!! In fact, right from the start I have never been able to connect to my account with the Adobe Application Manager, although I can do it directly from the Adobe site  ... The Adobe chat support told me that this problem is out of their expertise !!! therefore I had to go thru the burden of registering according to the off-line procedure.
    I am not really willing to update, fearing that Adobe will introduce again their EXTENDED version trial :-(
    Guy

  • Extend DLCI's over tunnels

    Looking for some working examples of extending frame relay DLCI's over GRE (etc...) tunnels. Hopefully without having to use MPLS or L2TPv3 (only have 36xx chassis to work with)

    Have you thought about using policy routing? I looked at a similar application once, although I never actually tried it.
    One of the options within policy routing allows you to send all specified traffic to another interface. My idea was to to apply the policy route to one (say) sub-interface with an ACL to match all packets, and set the next hop and a GRE tunnel. Then do the same in the reverse direction.
    I'd be interested to hear if this works.
    Andy

  • In iCal since update I cannot extend an event over days

    After recent update, in iCal on my iMac, for a new entry I am unable to set the event duration over days. Old entries no longer show the beginning date and the end date of events which have duration over many days. What happened? On the iPhone and iPad these options are still available.

    Hi Altjudi,
    What update did you install recently? What version os OS X are you running?
    In Calender (new iCal) You can set the view to week so you can see multiple days. Enter an event and hover your mouse at the bottom untill it changes to two arrows devided by a line. Click and hold, move mouse across the desired time period.
    If this doesn't work, answer the questions so we can help you further.

  • Extending a function over various frames?

    hi, this cursor follow works in a single frame on the main timeline with a stop action :
    // kisses start and follow cursor
    addEventListener(Event.ENTER_FRAME, start_kisses); 
    function start_kisses(event:Event) { 
    staged_kiss_mc.x = stage.mouseX;
    staged_kiss_mc.y = stage.mouseY;
    staged_kiss_mc.gotoAndPlay(start_kissin);
    MovieClip(this).stop();
    How can this same function be called in various frames throughout the main timeline? 
    For instance, say the above code is on frame one and the "staged_kiss_mc" is extended from frames 1 to 10.  On all frames there is also a stop action (along with additional code, content, etc.)
    How can the function "start_kisses" be activated on each of the 10 frames in the same way it is on frame 1 ?
    Is it necessary to add a new Event Listener? 
    Do new functions need to be coded for each frame, such as start_kisses1, start_kisses2, etc.?  --Or can the same original function be reused?
    Thank you

    Thank you that is interesting...so code can be "extended" down a timeline in the same way a movie clip can...until the next keyframe? 
    But if on layer A code is extended from frame 1 to frame 10...what happens when there are stop actions on each of the keyframes between 1 and 10 on layer B.  (Especially if in this case the code meant to be extended on frame 1 of layer A is an Enter Frame action...?) 
    Can a function such as:
    function dothis(event:Event) { 
    dosomething;
    be "called" on subsequent keyframes on layer B -- each has stop actions on each keyframe -- by using something as simple as:
    dothis();
    Is that possible?  To declare a function on frame 1 and then activate it again further down the timeline?
    If I rename the function slightly in each keyframe to avoid "duplicate function" errors, it seems like an excessive amount of code:
    [frame 1]
    function dothis1(event:Event) { 
    dosomething;
    [frame 2]
    function dothis2(event:Event) { 
    dosomething;
    etc
    That's not the correct approach...right?  (Can functions triggered by ENTER_FRAME events even be extended down a timeline? ...)
    Thanks for your time, very, very appreciated....

  • Extending SAN&LAN over dark fiber (DWDM)?

    Hi, sorry for my English, but I hope you understand me, and I understand your answers:)
    We are in the process of adding new data center (DC2), which will be geographically located about 20 km from our existing data center (DC1). Between them laid dark fiber (two fibers). We need a solution for the LAN(layer 2) and SAN(native FC) extension ...
    Solution is to see me use two passive EWDM-MUX8 at both ends of dark fiber with DWDM transceivers on the equipment in the DC1 & DC2.
    For Ethernet, we propose to use Cisco 10GBASE DWDM X2 Modules (p/n:DWDM-X2-xx.xx =) - equipment at both ends supports these modules.
    For FC we propose to use DWDM SFP Modules for Cisco ONS Family (p/n:ONS-SC-4G-xx.x =).
    SAN equipment at both ends - Cisco MDS 9124 (p/n:DS-C9124AP-K9).
    But I'm not entirely sure of the correctness of this decision, especially in SAN extension.
    Is this workable solution?
    Does the Cisco MDS 9124 supports this transceivers (ONS-SC-4G-xx.x=)?
    There are other potential pitfalls are not visible to me?
    In advance, thanks for the advice.

    For ethernet, your decision is correct.
    For SAN, things get a little dicey. The MDS 9124 doesn't support the ONS transcievers, and the FC 4G LH transciever is limited in distance to about 10 km.
    If it were me, I would do things a little differently. I would put a Nexus 5000 series at each end of your dark fiber, with a 20 GB etherchannel trunk between them. Each nexus would then be connected to your data center ethernet network via 10 gig ethernet, and to your MDS's via 2/4/8 gig FC. The nexus could then be set up such that FC traffic destined for the other end will be encapsulated in ethernet, sent over the link, unencapsulated at the other end, and sent to the appropriate FC host.
    It's relatively easy, simple to operate, and no mucking around with DWDM/CWDM, which can be a very complex animal.

  • Extend finder bar over two monitors

    is there any way to extend the finder bar (the bar at the top with FILE EDIT, time, etc, not sure what to call it) across two monitors? so that the apple and FILE EDIT, etc. controls are on the left monitor and it extends to the right monitor where the time, airport, display, sound, etc. controls are.
    I'm pretty sure you can't do this in MAC OS X, so i guess i'm asking if there is any software that can do this.
    Thanks!

    I have not heard of anything like that. There are some contextual menu (right-click menu) and desktop customization tools out there, I think.
    You can move the menu bar (and Dock) from one monitor to the other and change the relative position of the multiple monitors, just drag them around in the System Preferences Layout or Position view. The white menu bar can be dragged from one monitor to the other.
    I always have my Dock on the bottom, and it stays on the monitor with the Menu Bar, not sure what happens when you put it on the right or left sides and you have two monitors.

  • Extending 27" Cinema Display A Great Distance

    Hey all,
    I have purchased 2 cinema displays and I have my computer located about 100 feet away in a separate machine room. Normally i would buy a KVM extender to extend the display over Cat6. However since the LED cinema displays i have only have a Mini Dv Male as the only means of connection I've hit a bit of a road block. Can any one help or can any one point me to a female mini Dv adapter  or extender that is compatible with these Mac displays? Thanks!

    Sorry,
    Should have been more clear. I meant Mini- Display Port not dv. I have a 27" Cinema Display. I am comming out of my mac pro via DVI to a Gefen KVM extender. So Essentially I have a DVI Output from my computer and the only way to hook up my particular Cinema Display is via the Mini DisplayPort. SO i need a Female Mini-Display Port  to DVI-D Male but i have yet to find anything.

  • System copy export  -  error message unable to extend temp segment PSAPTEMP

    I am performing an export of ECC ABAP+java instance and during the export of the source system I get the following error during the ABAP export:
    ORA-01652: unable to extend temp segment by 128 in tablespace PSAPTEMP
    ORA-27072: File I/O error
    What do I need to do with this error? I have extended the tablespace via brtools but still getting the error.
    Is this because I did not select the shutdown instance during the export? or do I need to do something more via brtools to the PSAPTEMP tablesapce?
    I am running on Oracle 10.2.0.2. unix
    Thanks
    Mikie

    Hello Mike,
    >> My PSAPTEMP is 8GB.
    I would bet the table you try to export is bigger (if you export sorted.. you will need temp space)
    >> You have said you increased it to 800GB, that is almost a terabyte. Is this correct?
    >> If so, how did you arrive at this figure.
    As i already said .. this was the temp space that i needed in a sorted exported with many parallel exports (splitted packages and splitted tables). The system that i have migrated was round about 3 TB and we need to do it very fast.. so i needed the temporary space for the many parallel actions... but this should not be the "normal" case if you have no specific values.
    >> And if you could define how you extended PSAPTEMP. Did you use brtools?
    I have extended it manually (over sqlplus) .. i have monitored it in my test cases with the view V$TEMPSEG_USAGE and increased it if necessary.
    >> did you recreate PSAPTEMP via SQLPLUS size 800GB and then dropped it and recreated to normal size?
    No, in my case i have exported and imported it at the same time (distribution monitor) so there was no need to drop it after the export, because i have build up a new target database. But under normal conditions you would only drop the tempfiles after your work has been done. This is possible with Oracle 10g (with some restrictions).
    => http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_3002.htm#i2093894
    Restrictions on Dropping Files To drop a datafile or tempfile, the datafile or tempfile:
    - Must be empty.
    - Cannot be the first file that was created in the tablespace. In such cases, drop the tablespace instead.
    - Cannot be in a read-only tablespace.
    Regards
    Stefan

  • Uninstalling PS CS4 Extended after upgrading to PS CS5 Extended

    I finally acclimated to my upgraded to PS CS5 Extended after transferring over presets, brushes, actions, etc and decided to uninstall CS4.  Of course now when I open CS5, I receive an error message indicating the some of the support files are missing and I need to reinstall PS CS5.  Since this was an upgrade from CS4 that is no longer on the computer, do I need to reinstall CS4 and then reinstall the upgrade to CS5?  Or is there a way to simply reinstall CS5 and be done with it?  Since this was an upgrade purchased via download, and I deleted the disk image, where do I find the download for the upgrade?  Any help or suggestions are much appreciated.

    All Adobe updates are full installers.
    If the update installer does not find a qualifying prior version installed, it will simply prompt you for the old serial number as well as the new one.

  • Can I add a second Airport Express using an Ethernet cable to extend my network if the first AX is wirelessly connected to an Xtreme?

    Hi, I run a small motel and I am trying to extend the wireless network from the office to the rooms in the next building.
    I have an AirPort Xtreme connected to my router with an ethernet cable and it works fine.  I have then connected an AirPort Express to this in the next bulding wirelessly (as i cant run an ethernet cable outside) which extends the network over all but the last 2 rooms in the next building.  There are bick walls so it sruggles over the distance.  I realise I cant connect another airport express wirelessly to extend the network further but can I connect another Airport Express using and ethernet cable to the exisiting Aiport Express to extend the network that extra distance?

    You can do this, but as you might imagine, that is going to place even more of a load on the weakest link....the wireless "hop"......between your AirPort Extreme and the current AirPort Express.
    So, things will slow down even more. Whether or not that will be acceptable to your guests is open to question. Light browsing and email should be OK. Someone trying to download a large file is going to be waiting longer than they might consider normal.
    Things like this, you simply cannot predict in advance. Might be a good idea to understand the store's return policy if the new Express puts more of load on the network than is expected.

  • Desktop extended onto two external monitors

    My T400s has two ports for external monitors.  Will i be able to extend my desktop over the built-in screen as well as the TWO external displays--giving me a total of three screens?
    Thanks.
    Peter
    p.s. Where is the 'search' feature on these pages?

    prehmer wrote:
    p.s. Where is the 'search' feature on these pages?
    Waaay down at the bottom!
    I don't work for Lenovo. I'm a crazy volunteer!

  • Use Airport Express Brick N to extend network via ethernet

    I have the old brick-style Airport Express N model, which I'm currently using to extend the newer Airport Express hockey puck. The hockey puck is setup to with DHCP and creating the network. The brick is in setup to extend the network using DHCP and in Bridge Mode. When I plugin the Ethernet cable from the Ethernet port of the hockey puck to the brick, I lose all internet connectivity. I seem to recall reading some documentation that said the brick would support ethernet rather than just over-the-air. Thanks for your help!

    My question is: can I connect the two via ethernet cable to the extending is happening over the air? I'm not sure the brick is capable of this?
    It is possible to "extend" in two different ways:
    1) Extend using a wireless connection between the AirPorts. Apple calls this "extend using wireless" during the setup. When you extend this way, about half of the potential speed on the network is lost.
    2) Extend using a wired Ethernet connection between the AirPorts. Apple calls this "extend using Ethernet" during the setup. When you extend this way, full bandwidth on the network is maintained since there is no signal loss in a wire.
    If you want to "extend using Ethernet", the 2nd Gen AirPort Express must be the "main" router, so you will need to reconfigure it for that purpose. The 1st Gen will also need to be reset back to default settings and reconfigured as well.
    Once the 2nd Gen Express is working correctly as the main router, connect an Ethernet cable from the LAN <--> port on the 2nd Gen Express to the Ethernet port on the 1st Gen Express and use AirPort Utility for the setup.

  • Data rate slows over time: Using Time Capsule (4th) and AirPort Express (1st)

    Time Capsule using Airport Express to extend network.
    Over 3-4 days my data rate gradually gets slower and slower until I have to reboot both TC and AE.
    Fresh reboot gets me 10Mbs or better for a while and then slows over time to 2Mbs or less.
    I can cable directly to the ISP modem, taking TC and AE out of the equation, and its smokin fast
    No hair left to pull out, so any help or suggestions would be appreciated.
    Time Capsule (4th gen) - Model A1409
    Version - 7.6.4
    Wireless Mode:  Create a wireless network
    Wireless Security:  WPA2
    Channel:  149 (Automatic), 11 (Automatic)
    Allow this network to be extended is checked
    Radio Mode:  Automatic
    Multicast Rate:  Low
    Transmit Power:  100%
    Use wide channels is checked
    Guest Network is NOT enabled
    Mac Address Access Control: Not Enabled
    Connection Sharing:  Share a public address
    Using DHCP
    One printer attached to Time Capsule
    Airport Express (1st gen) - Model A1143
    Version 7.6.4
    Wireless Mode:  Extend a wireless network
    Wireless Security:  WPA2
    Channel:  11 (Automatic)
    Mac Address Access Control: Not Enabled
    Using DHCP

    You have your wireless channels on auto.. it is usually better to control it.
    You will notice I have different names for 2.4ghz and 5ghz.. then I can force the link to either band.
    After you set Radio Channel selection to Manual,, click edit. You can then set the channels.
    Lock the channels.. ie you take control and you set what the wireless channels will be.. when you extend wireless this works far better. The auto channel system has to run on the Extender.. but since the main base is fixed on the 2.4ghz so it will be also.. the only channel that can flap around is 5ghz (extender) since that is not under my control. Of course it is up to you to determine which channel works best.. I strongly recommend the upper channels for 2.4ghz and the lower channels for 5ghz.
    So.. I have set 5ghz to 48 on the main base.. and the auto channel sets it to 149 in the extender.
    One strange thing results from my setup .. (amongst many!!)
    You cannot name the wireless for 5ghz in the extender.. so in my case the upstairs wireless extender has both 2.4ghz and 5ghz named TC24ghz.. nought that I can do about it. But it is not a big deal.
    You can see the result in the wireless diagnostics. The last wireless I have put in the box.. it is named TC24ghz but is in fact running on 5ghz. That is just how the over automated system of the apple routers work.. If I could I would fix it.. and maybe shall via serial console at a later date.

  • I am planning on getting the disk version of the teacher's edition of CS6 Extended.

    When the CS6 Externded version comes out, do I install it over the CS5.5 extended version or over the CS6 PS.  Or, is it a complete new install?

    Hi,
    Sorry, I don't believe Adobe has announced anything regarding specifics on availability or pricing for Ps CS6.
    You can request to be notified when Photoshop CS6 is released by going to this link:
    http://www.photoshop.com/products/photoshop?notify=ps_cs6
    regards,
    steve

Maybe you are looking for

  • Display Message from automatically FOX-Formula

    Hello, we are using a FOX-Formula as automatically Function "After data change" within the planning-layout (WebInterface). Does anybody know, how we can tune the function / layout, that we will see this message if the conditions agree? For example: I

  • Price in Bid Invitation is missing

    Hi all, I'm creating the Bid Inv. from the shopping cart or from the Purchase Requisition (backend), but it creates with Item Value  0,00 on the tab Item Data. But in SC or PR the price is maintained. The simple prising is active, and there is no IPC

  • Get-ADUser : The server has returned the following error: invalid enumeration context.

    I'm running a powershell command to add the email (AD mail) attribute to users in a specific OU.  It seems to work then will bomb out with the error in the title. I'm using a "scripting guy" command that I've altered with my specfic OU/domain informa

  • What is error code cmob 0x002 on demand?

    I get error code cmob 0x002 when I try to scroll through movie titles to find the one i want to watch on my on demand channel. This has been happening for 2 days now.

  • Relais a 2 RT ???

    Bonsoir, comme le titre l'indique je ne trouve pas un relais a 2 RT, je trouve seulement a 1 RT j'ai tenter de bricoler un montage hsitoire d'avoir un a 2RT mais sa marche pas je vous envoie des piece jointe pour mieux comprendre, biensure j'ai mis s