3
讓我直接點,多個UIScrollView
有3滾動像喜歡附件,我很困惑的代表。 看到的鏈接: image screenshoot
在這裏它是:
- 渦旋件1 - 可滾動自由(水平/垂直)
- 滾動 - 僅
- 渦盤2垂直滾動3 - 僅限橫向滾動
,我想打,如果我是滾動「滾動2」水平那麼「滾動1」是滾動了。 如果我滾動「滾動2」垂直然後「滾動3」也滾動。
如果有示例代碼/示例,它會很好。
關於,
天空。
讓我直接點,多個UIScrollView
有3滾動像喜歡附件,我很困惑的代表。 看到的鏈接: image screenshoot
在這裏它是:
,我想打,如果我是滾動「滾動2」水平那麼「滾動1」是滾動了。 如果我滾動「滾動2」垂直然後「滾動3」也滾動。
如果有示例代碼/示例,它會很好。
關於,
天空。
我做了類似於兩個NSTableViews的事情,滾動一個會進行第二次滾動。
下面是該代碼:
MyScrollView.h
#import <AppKit/AppKit.h>
#import "AppDelegate.h"
@interface MyScrollView : NSScrollView
@property (strong) AppDelegate *app;
@end
MyScrollView.m
#import "MyScrollView.h"
//#define LogRect(RECT) NSLog(@"%s: (%0.0f, %0.0f) %0.0f x %0.0f", #RECT, RECT.origin.x, RECT.origin.y, RECT.size.width, RECT.size.height)
@implementation MyScrollView
@synthesize app;
- (void)reflectScrolledClipView:(NSClipView *)aClipView{
[super reflectScrolledClipView:(NSClipView *)aClipView];
//post a notification
app=[[AppDelegate alloc] init];
if (app) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"scrolled" object:aClipView];
}
}
@end
AppDelegate.h
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (strong) IBOutlet NSTableView *aTableView;
@property (strong) IBOutlet NSTableView *bTableView;
@property (strong) IBOutlet NSTableView *cTableView;
@property (strong) IBOutlet NSView *aView;
@property (strong) IBOutlet NSView *bView;
@end
AppDelegate.m
#import "AppDelegate.h"
@implementation AppDelegate
/*
Unwanted methods are not shown here, like delegates, datasource, init etc
*/
-(void)scrollTable:(NSNotification *)aNotification{
NSPoint globalLocation = [NSEvent mouseLocation ];
NSPoint windowLocationForA = [[aView window ] convertScreenToBase:globalLocation ];
NSPoint viewLocationForA = [aView convertPoint: windowLocationForA fromView: nil ];
NSPoint windowLocationForB = [[bView window ] convertScreenToBase:globalLocation ];
NSPoint viewLocationForB = [bView convertPoint: windowLocationForB fromView: nil ];
if (NSPointInRect(viewLocationForA, [aView bounds])) { // i scrolled on A
NSLog(@"Scrolled A");
if ([[[aTableView superview]superview] isEqualTo:[[aNotification object] superview]]) {
[bTableView scrollRectToVisible:[[aNotification object] documentVisibleRect]];
[cTableView scrollRectToVisible:[[aNotification object] documentVisibleRect]];
}
}
else if (NSPointInRect(viewLocationForB, [bView bounds])) { // i scrolled on B
NSLog(@"Scrolled B");
if ([[[bTableView superview]superview] isEqualTo:[[aNotification object] superview]]){
[aTableView scrollRectToVisible:[[aNotification object] documentVisibleRect]];
[cTableView scrollRectToVisible:[[aNotification object] documentVisibleRect]];
}
}
else{ // i scrolled on C
NSLog(@"Scrolled C");
if ([[[cTableView superview]superview] isEqualTo:[[aNotification object] superview]]){
[aTableView scrollRectToVisible:[[aNotification object] documentVisibleRect]];
[bTableView scrollRectToVisible:[[aNotification object] documentVisibleRect]];
}
}
}
-(void)awakeFromNib{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(scrollTable:)
name:@"scrolled"
object:nil];
}
@end
Wow..so它不是那麼簡單的實現滾動委託,我能使用類似scrollviewdidscroll什麼? – discodisky 2013-02-26 05:12:37
我搜索了近15天的上述內容,並以上面的代碼結束。 – 2013-02-26 09:02:01
這不解決你的問題或給你任何想法? – 2013-02-26 09:08:42